I am having getting PayPal to update shipping options based on country when a customer selects their shipping address.
I am attempting to use the Paypal Instant Update API and have followed the instructions but to no avail.
I am currently just using the Paypal Sandbox; but it doesn't seem to behave.
I am able to generate what I believe is the correct response and send it, however Paypal just uses the defaults set with the initial request. Logs show the response being sent, I've even put the response in to a database so I can see what it was (and it is as expected).
I've tried may things http, https, disable gzip, urlencode, file with static content, and nothing seems to be working. Here is what my response currently looks like:
METHOD=CallbackResponse&L_SHIPPINGOPTIONNAME0=2nd+Class&L_SHIPPINGOPTIONLABEL0=2nd+Class&L_SHIPPINGOPTIONAMOUNT0=1.50&L_SHIPPINGOPTIONISDEFAULT0=true&L_SHIPPINGOPTIONNAME1=1st+Class&L_SHIPPINGOPTIONLABEL1=1st+Class&L_SHIPPINGOPTIONAMOUNT1=2.00&L_SHIPPINGOPTIONISDEFAULT1=false&L_SHIPPINGOPTIONNAME2=Special+Delivery&L_SHIPPINGOPTIONLABEL2=Special+Delivery&L_SHIPPINGOPTIONAMOUNT2=6.00&L_SHIPPINGOPTIONISDEFAULT2=false
I really don't know what I'm doing wrong, and Paypal don't seem to offer any way to debug callbacks. Any help would be very much appreciated :)
Related
I really need help because I don't know what to do at this point. I developed a website where the new user need to pay for sign up, I set the correct paypal form button and about the money everything works ok, the problem is that I can't update my database. I'm using these files (they are provided on gitHub and also in the official Paypal guide there's a link to them): "PaypalIPN.php" and "example_usage.php". I also added to my Ubuntu cloud server (where is my website) the cert/cacert.pem, I don't know if I had to do but in the first file seems to be required.
I tried to run a IPN simulator but it doesn't work, I looked for the same problem and I found that there may be a problem with the simulator, so I made some real transactions (I've read that live production test is run correctly with that code).
Therefore:
the transaction money is ok;
in the Instant payment notification history there are all test I made and in message ID I can read the correct data passed in the IPN message, the IPN type is "Transaction executed" and the response code is 200. I noticed that in "example_usage.php" the 200 response code was out of the if ($verified) so, just for my last test, I put that inside the if and yes, the response was again that;
I tried my code for update the mongodb database with fake data and obviously it works.
How is it possible? Please, help me and thank you.
Did you verify the correct URL is showing in the IPN History details? Sometimes people are using a button that uses notify_url to override the PayPal account setting, and then IPNs are working, but they're going to a different place than expected. So check that first.
If the IPN is indeed going to the URL you expect, and it's returning a 200 OK, that means it's receiving and completing the script successfully. If you aren't seeing the expected result in your database then you must have some sort of a logic problem with your code that needs to be addressed. You need to build in some trackers to log files or send yourself emails as it does each step of your script to see if that portion of code is actually getting hit like you think it is.
I put together this article for how to test PayPal IPN a while back that has proven helpful for many people. If you follow the steps there you should be able to track down the problem.
I have been working on the following workflow using Paypal Payments.
My intent is to send the Customer to the Guest-Payment-Website. He should not see paypals login-page at first.
This is because many people do not know that they can pay with Creditcard or Bank-Transfer without registering an Account.
I had my whole process tested within the sandbox and it worked. Then I changed to the live-version and $flowConfig->setLandingPageType("billing"); it is not affecting the landing-page anymore.
Workflow:
I prepare some new Webprofile() which is setting things on paypals payment-approval-site (logo etc., shopname). It is saved once and identified by some string (XX-XXXX-XXXX-XXXX-XXX)
I prepare a transaction and send it to paypal.
Then the Customer is sent to the specific payment-approval-site on paypal.com
the customer should put in his authentication there
the customer is sent back to my website
To preset visual options I predefine some Webprofile.
$flowConfig = new \PayPal\Api\FlowConfig();
$flowConfig->setLandingPageType("billing");
$presentation= new \PayPal\Api\Presentation();
...
$inputFields= new \PayPal\Api\InputFields();
...
$webProfile = new \PayPal\Api\WebProfile();
$webProfile->setName("GuestPaymentProfileNameasdf")
->setFlowConfig($flowConfig)
->setPresentation($presentation)
->setInputFields($inputFields);
$webProfile->create($APIauth)
This create-command is giving back some string (XX-XXXX-XXXX-XXXX-XXX) which is saved within paypal to identify this set of options i put into the system.
...
$payment->setExperienceProfileId('XX-XXXX-XXXX-XXXX-XXX'); //profile ID
...
Does anyone know what I could do wrong here? As written, this is totally working within the Sandbox but when I switch to LIVE the customer always is sent to the normal login-page.
Is there some other method to do this?
Did I miss some hint or depreached sign?
I have been working on this and the cause of this behaviour seems to be the limitation of my Paypal-Account within Germany.
At first I was able to buy as a guest. Then this option vanished - probably with the expiring of my sandbox-infused cookie.
So I called the support of Paypal today and asked some specific questions.
I had other expectations about this guest-buy-functionality, because I got used to the unlimited US-Sandbox-Account. My personal mixup might be caused by a possible internal mixup of options / restrictions / limitations when you change from the unlimited sandbox to your restricted live-account.
The Thing is, that I should not have seen this guest-billing-page within germany - but it worked... once after going live.
I'm trying to understand if it's convenient for a client to switch from Paypal Express Checkout to Braintree, but I find the latter way too complicated and hard to understand (terrible docs, only reference is good).
Documentation lacks COMPLETE WORKING examples, with all the pages needed where you can just change API credentials and everything works. That is fundamental for any system/API to get quickly the logic and workflow.
I basically currently have a checkout system with all my customer's data and a basket_id, with a form a redirect customer to Paypal passing all these data, and once the customer completes the payment Paypal calls back a URL on my server sending back all the data I sent plus transaction id, and this way I mark that basket_id/order as paid and assign to it a transaction. And no sensitive payment data are typed or pass through our server/network.
How to do all this on Braintree js+php? Any full and complete sandbox working example where I can just change my credentials and have working code to understand the logics? Is much faster than reading the honestly quite confusing documentation.
Thanks!
I am using the Paypal Express Checkout and everything working good except the shipping carrier not being updated when the Callback is being called.
I can verify the callback is being called (call is logged).
When Paypal call the callback URL with the customer shipping country I return the following values.
METHOD=CallbackResponse&OFFERINSURANCEOPTION=false&CURRENCYCODE=USD&TOKEN=EC-5Fsdf5523823&LOCALECODE=en_US&L_SHIPPINGOPTIONNAME0=USPS&L_SHIPPINGOPTIONLABEL0=First+Class+%283-7+Days%29&L_SHIPPINGOPTIONAMOUNT0=0.00&L_SHIPPINGOPTIONISDEFAULT0=true&L_TAXAMT0=0.00&L_INSURANCEAMOUNT0=0.00&L_SHIPPINGOPTIONNAME1=USPS&L_SHIPPINGOPTIONLABEL1=Priority+%282-3+Days%29&L_SHIPPINGOPTIONAMOUNT1=7.95&L_SHIPPINGOPTIONISDEFAULT1=false&L_TAXAMT1=0.00&L_INSURANCEAMOUNT1=0.00&L_SHIPPINGOPTIONNAME2=UPS&L_SHIPPINGOPTIONLABEL2=Next+Day+Air&L_SHIPPINGOPTIONAMOUNT2=39.95&L_SHIPPINGOPTIONISDEFAULT2=false&L_TAXAMT2=0.00&L_INSURANCEAMOUNT2=0.00
The Callback message is being echo'd through PHP (I even tried save this as a txt file and point the callback URL to this file), even then Paypal doesn't update the Shipping Method.
I also changed CALLBACKTIMEOUT to 6 seconds but it doesn't matter. I am using HTTPS and also tried it with normal HTTP.
I am testing this in sandbox mode.
Anyone could help me out? I am really stuck here and I have been searching for similar problems but couldn't find any.
For your information I followed this Paypal guide : https://developer.paypal.com/docs/classic/paypal-payments-pro/integration-guide/WPInstantUpdateAPI/
I also checked if I am returning all the required fields as described here :
https://developer.paypal.com/docs/classic/api/merchant/Callback_API_Operation_NVP/
I hope someone can help me out, thanks in advance!
UPDATE
I try the NO SHIPPING OPTION
METHOD=CallbackResponse&NO_SHIPPING_OPTION_DETAILS=1&CALLBACKVERSION=95.0
Paypal responds with 'doesnot ship to this location. Please use a different address.'
So the response url is working, the problem is when responding with other shipping options.
Regards,
Kuroudu
I was having the same problems as you, but then I tried the example code from the PayPal Instant Update integration guide and added it as a text file on my server:
METHOD=CallbackResponse&OFFERINSURANCEOPTION=true&L_SHIPPINGOPTIONNAME0=UPS+Air&L_SHIPPINGOPTIONLABEL0=UPS+Next+Day+Air+Freight&L_SHIPPINGOPTIONAMOUNT0=20.00&L_TAXAMT0=2.20&L_INSURANCEAMOUNT0=1.51&L_SHIPPINGOPTIONISDEFAULT0=false&L_SHIPPINGOPTIONNAME1=UPS+Expedited&L_SHIPPINGOPTIONLABEL1=UPS+Express+2+Days&L_SHIPPINGOPTIONAMOUNT1=10.00&L_TAXAMT1=2.00&L_INSURANCEAMOUNT1=1.35&L_SHIPPINGOPTIONISDEFAULT1=true&L_SHIPPINGOPTIONNAME2=UPS+Ground&L_SHIPPINGOPTIONLABEL2=UPS+Ground+2+to+7+Days&L_SHIPPINGOPTIONAMOUNT2=5.99&L_TAXAMT2=1.99&L_INSURANCEAMOUNT2=1.28&L_SHIPPINGOPTIONISDEFAULT2=false
This at least gave me a CallbackResponse that finally worked which I then could update with programming to make it function the rest of the way. Spent many hours ripping my hair out. As PayPal doesn't really provide any means of debugging the CallbackResponses, I was happy to have a functioning starting point.
Hopefully this helps to point others in the right direction.
I have successfully posted my custom shopping cart to PayPal -- it processes the order just beautifully, and when the payment is received, it posts data back to the URL I specified in the config. The code is based on the library found here: http://www.phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/
So I'm successfully verifying the IPN by posting data back to PayPal -- that is all great. Here's my dilemma -- how do I know what order the IPN is confirming?
I am not making use of PayPals shopping cart, I have my own. It has it's own cart ID in my database, and when I receive an IPN for that cart, I'd like to "close" the cart and save it as an order to be looked up at a later date.
I've tried passing an additional custom field along with the redirect to PayPal that populates the cart, but that value isn't returned back to me in the IPN. The documentation on x.com is just plain lacking so I've found no help there.
Does anyone have any experience with PayPal and IPN? Doesn't necessarily have to be with PHP -- I can interpret code -- but if you have a way to send a value to PayPal with an order and then have that value returned with the IPN, that is AWESOME!
If this isn't possible with PayPal's API (which I would find hard to believe) -- any other suggestions on how to handle this?
I do not know if this is a good idea or not, but here are a couple different options:
A: Use the first set of on1 / os1 for the item 1 and add the order id to that.
B: In the custom field, I am not sure what you have in there, but you can make it something like orderidhere41|otheritems here and then just parse this out by exploding at the | to get them separated.
Paypal does limit this, and I do not know why, but both of those should work. Doing it as an on / os will put it on the paypal receipt for the user, so that is my preferred method.
If someone else has a better solution, I would be interested in it as well!
EDIT:
Clarifying on1 os1. These are "options" generally used for Size / color etc. See IPN PDT Paypal variables under option_name1 option_selection(sp) for more information on them. The name of course is the title which would be "Order ID" the os would be the actual id.
EDIT:
Looking through that documentation $my2CO->addField('cart_order_id', rand(1, 100)); is where I would put my own cart order id. That should be the correct field. Sorry for the confusion :)
EDIT:
In the end there is a custom field for the paypal IPN, called "custom" adding data to this will pass through, this will transfer the orderid for you to and from. It must be called custom on both sides.
(this may be different for the other API's).
My experience has been with the Express checkout via C#, but the process should be the same even in PHP. If you're using the Name-Value Pair (NVP) interface right before you redirect the user to PayPal you hit the PayPal site to retrieve the redirection URL. As part of their response they pass back a token to you. You save this token along with your order. When the IPN postback occurs you get this same token back which lets you look up the original order.
The process flow looks like this ("You" being your site):
User fills cart, clicks button/link to check out
Request is sent to your site
Your site receives request, sends data to PayPal
You get an initial response from PayPal which contains a token
You save this token along with this user's shopping cart.
You redirect the user to the link returned by PayPal
User is redirected to PayPal and enters payment info
Payment info is validated by PayPal
User is redirected back to your site
PayPal sends IPN response back to your site
You grab the token included in the response
You look up the token you previously saved to find the shopping cart (they are the same value)
You close out the initial order/shopping cart.
You might want to try out the PHP SDK - scroll down to the Name-Value Pair Interface.
I very much doubt this will help the original poster, but PayPal have either added, or finally documented the option "invoice" which allows you to post the OrderID, and have it posted back via the IPN.
I am currently using this and it seems to work as expected.
For further info see the Website Payments Standard Integration Guide (PDF): Appendix A, Table A.4
You can create and post a custom pass-through variable that's 255 characters long that could hold any data. More info on page 44 in the official Paypal IPN Guide.