Magento placing order before paypal payment - magento

i've a problem with paypal integration in magento.
If i choose paypal standard payment and confirm order, i'm correctly redirect to paypal site for payment, but if i press back button on the browser i am redirected in /checkout/cart (that is empty) and in my backend my order was placed and in PENDING status (it's not shown in customers order list)...
This happens because the order were placed before payment processing...
In OnepageController.php saveOrderAction method i can see
$this->getOnepage()->getQuote()->save();
/**
* when there is redirect to third party, we don't want to save order yet.
* we will save the order in return action.
*/
if (isset($redirectUrl)) {
$result['redirect'] = $redirectUrl;
}
What does it mean? It is exactly what i want "Don't want to save order yet....", unfortunatly few rows before...
$this->getOnepage()->saveOrder();
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
And the order were already placed....
I hate editing core file, but i've tried to comment the line above, but an exception shows me that order information are used inside paypal module itself (Standard.php file method getStandardCheckoutFormFields). So i can't modify core file easily....
What am I missing?
Thanks a lot and excuse me for my bad english.

You can use for this purpose PayPal express checkout. It works the way you want.

I'm dealing with exactly same problem as you were.
For now i'm thinking of rewriting onePage Model and saveOrder action in my module.
What Im thinking of is to remove part where session is cleared and make an event to observer after receive payment method response.
No idea if it'll work but well.

Related

note passed in as part of CreateCheckoutRequest, but where to on the payment page or the dashboard to view them?

I am using nodeJs, and I have passed in note inside CreateCheckoutRequest, however, i am not seeing the note showing on the payment page url generated by createCheckout or the dashboard page.
My ultimate goal is our frontend can pass in the phone number as note to sqaure-connect, so that we can view the phonenumber from our dashboard once the customer completes an order
Tried to look at old transactions, since we didnt use note, didnt see any note.
const checkout = SquareConnect.CreateCheckoutRequest.constructFromObject({
idempotency_key: 'sample_key,
order: orderRequest,
redirect_url: redirect_url,
ask_for_shipping_address: true
note, // need to see it from dashboard once the user completes an order
});
When adding a note to a CreateCheckout request, it will end up on the tenders->note field of the associated transaction. To clarify, once the customer has paid on the checkout page, it should redirect to your web page (based on your redirect_url field that you passed to CreateCheckout originally). From there, the url will contain a parameter called transaction_id. You can then use this id to retrieve the transaction and digging into it to find the note (transaction->tenders[0]->note). In this particular use case, there will always only be one tender since Checkout doesn't allow multiple tenders.
Now, to actually answer your question: the tender note will be displayed as the main text you see when you view your transactions. So when you login to your Square Dashboard and click Transactions, in the main list, the "header" will be whatever the tender note was.

Laravel Paypal checkout

Json view of my paypal after payment is made
I am desperately trying to access the description which is under the transactions array but can't seem to find a way!
It's totally different if I want to access payment_method for instance all I do is this:
(By the way, I assigned this array to $method)
$method->payer->payment_method , but the same thing doesn't work if I want to access description. All I get is an error.
I'm using laravel 5.5, in case that makes a difference.
I'm doing this because I need to find a way to reference my product in the final page after the paypal payment has been made.
Looks like transactions in an array so if you would like the description of the first one that would look like this.
$method->transactions[0]->description

WooCommerce - checkout - AJAX billing address check error

I have a problem with WooCommerce's checkout form (WooCommerce version 2.4.7). I sell a physical object and I have guest purchases enabled (with an option to register). I skip the cart, because it's unnecessary in my case. Anyway, when I input the billing address, at the end, AJAX call to checkout/?wc-ajax=update_order_review is made and the data returned from call is as follows:
{"result":"success","messages":"","reload":"false","fragments":{".woocommerce-checkout-review-order-table"
:"<table class=\ ... "}
The result is success, but the fields get emptied and the user is therefore prompted to input the address again and again ... with no success. I use the very well known Avada template and I don't really know, where to start debugging. I don't think it's the template issue.
Can anyone help?
For anyone who encountered this kind of problem, the solution seems to be to not to include the checkout.js file, which takes care of "AJAXy" stuff on Checkout page. You then have to do the input checks yourself.
The solution: Disable AJAX on checkout for WooCommerce
Have a nice day!

Magento: redirect to select payment method

I am working on a custom payment method for magento. In case of errore during the "place the order phase" I would like to redirect the user to "Payment Information" (i.e. the part of the ceckout process during which the user selects the payment method).
Is there any way to achieve this and output any possible error?
Well, if by "place order" you mean the final process, which means "save order".
I suppose you put these lines in your main payment model.
public function getOrderPlaceRedirectUrl(){
return Mage::getUrl('yourmodule/yourcontroller/yourmethod');
}
In yourmethod, deal with exceptions (search by 'try catch - php').. and when you get one of these exceptions, redirect to your onestep page.
Unfortunelly, at this point (onestep) page, i don't know exactly how you can focus on payment method. But , just take a look at the calls in that phase that you can figure it out.

Increase shipping price and/or add line item for extra cost

I'm implementing a custom FedEx integration solution for a Magento site. Part of this is to add a signature requirement checkbox in the onepage checkout, and add $3 if this is checked. Unfortunately it seems that the FedEx Rate Web Service doesn't take any parameter regarding signature requirements, so I must manually add this cost to the order.
I was thinking about taking one of these two approaches, but I'm not sure will be best nor am I sure how to actually accomplish it:
Add $3 to whatever price FedEx returns
Create a new line item for this
Assuming that I have a handle on the $order, which solution would be best and how would I do it?
The code should run inside an observer method which is called by the checkout_controller_onepage_save_shipping_method event, which is triggered immediately after $this->getOnepage()->saveShippingMethod($data);. This means I can't add $3 when the FedEx API returns a result, as I won't know if the checkbox is checked until afterwards.
I came up with a solution; it's not the best but it works perfectly fine for me:
Magento fires an event when saving the shipping info. I grab the POST data and save it in the db as well as the address object.
If the checkbox has changed, have it reload that same tab instead of moving onto the payment step.
In the shipping quote, check the address object for the checkbox value. If set, add a certain amount to the quote result.

Resources