Handling errors during Paypal payment execution - php

I'm using PayPal REST API v1 for handling payments and from time to time I get errors during payment execution (.../payments/PAY-XXXXXX/execute). Specifically I have run into TRANSACTION_REFUSED and PAYMENT_STATE_INVALID so far. What is the correct way to handle them? Documentation isn't very extensive about these.
From what I understand, TRANSACTION_REFUSED means a problem with Payer account such as rejected card transaction or insufficient funds. In that case I display an erro message that PayPal has refused the transacation and user should try again. Is this a way to go?
PAYMENT_STATE_INVALID is a mystery to me. I get that the payment should be in another state but how do I check if it has a correct state after creation? And how should I handle this error?
Thanks for any suggestions!
I'm using standard php sdk, version from 5. 5. 2014.

This is only a partial answer to the PAYMENT_STATE_INVALID question. You can get the current status of the payment by fetching the "self" URL you initially got from the payment. That way, you can confirm the state of the payment, and maybe try and deduce why it's in the wrong state.
In my judgment, you should need to "handle" this error, since if you do the preceding steps correctly, the payment should always be in the correct state when you try to execute it.
As for the TRANSACTION_REFUSED question, I too would very much like to know.

Related

Paypal CreateRecurringPaymentsProfile causing a timeout

I'm trying to complete a transaction on paypal sandbox and my request always return timeout error.
I've look everywhere for this problem that seems to be pretty recurrent but no solutions seems to work for me.
Thanks!
Finally, I've found solutions to my problem.
as pointed out by ppmtscory on the php-Paypal-SKD github forum, you shoud not use credit card number 4111111111111111 because it as been overused and it is flagged as so in the system and cause this type of behavior.
https://github.com/paypal/PayPal-PHP-SDK/issues/519
#artisangang I will be closing this issue as it doesn't have to do with the SDK itself. This is due to the specific testing card number being overused in the system causing a timeout. #pp-randy has already filed the internal ticket to do a DB update to try and correct this for the sandbox environment but it's not something that will likely get very high priority. If you need test credit cards, please visit this page and utilize Step 4.

Paypal transaction completed but empty response from api (Random)

I am using PayPal API of php. It was ok since 2 years but now its creating problems for some customers. Some of the orders are fine but for few users, the transaction is completed but API doesn't response (throw empty response).
I don't think it will be because of code issue. I am unable to track the issue. Anyone know, why it's showing the random behavior.
The interesting thing is, for the same customer, doing the second time transaction, it works fine. Totally random behavior. Please need expert suggestion.
Please contact PayPal Merchant Technical Support, provide with your PayPal account and API request example which go empty response.
https://www.paypal-techsupport.com/

php express checkout recurring created profile successfully but recurring not working

we have implemented express checkout very well.
we get ipn response for each transaction.
we done these thing in sandbox.
now we are making recurring payment with express checkout.
here the recurring profile is creating proper,
But i am not getting any ipn notification for transaction and also not any transaction is done for that profile.
Can anyone suggest me solution for this issue.
Help will be highly appreciated.
Thanks
vijay
Recurring Payments transactions send IPN's just fine, so my guess is your IPN script must not be handling them correctly or maybe just "doing nothing" with them. For example, if you're only handling a specific txn_type, then you might be missing out on other stuff.
Log in to your PayPal account and check your IPN History and you should see a list of all the IPN's it's been sending. You can see if it's returning Success or Fail, there, because another possibility is that your IPN script is simply failing when a certain txn_type hits it.
Your own web server logs can be a big help when troubleshooting that sort of thing, too. If you are getting some IPN's, though, it would be sending them all, so something must be going on to make you think they're not sending when they are.

Paypal express checkout session expired / token invalid - Error 10411

i have a big Problem.
I build my own Shop and now i'm trying to integrate Paypal.
I successfully integrated Paypal with Sandbox. Now that I'm changing to the Live Mode an Error appears:
API Error 10411 - This Express Checkout session has expired. Token value is no longer valid.
It doesn't make any sense..
Normaly this Error appears if the client needs to much time to complete the transaction, but i don't need more than 30 seconds.
Actually everything works until reaching the return-Site, here comes the answer "FAILURE" and this error message.
The strange thing is, that everything works fine with Sandbox, but in the Live-mode my token is invalid. I checked the API Name, Password and Signature almost a hundred times and it should work.
Does anybody has any ideas why this Error appears?
Thanks for your help!
I had the same problem.
My mistake was :
- SetExpressCheckout was made toward paypal sandbox
- GetExpressCheckoutDetails was made toward real Prod Paypal
So double check that the Token you get from PaypalSandBox is used with PaypalSandbox (and same thing for real Paypal)
i had the same issue, and i was in sandbox mode when checking the token. so always be sure to test against the LIVE system and not the sandbox

Paypal Checkout Express empty cart problem

I'm working on Paypal integration in my website, following Paypal's API specifications. I'm testing it in a sandbox, and after sending a SetExpressCheckout request like this:
CURRENCYCODE=EUR
&RETURNURL=http%3A%2F%2Fwww.xxxxxxxx
&CANCELURL=http%3A%2F%2Fwww.xxxxxxxx
&PAYMENTACTION=Sale
&L_PAYMENTREQUEST_0_NAME0=T-shirt+ring-spun+attillata%3B+taglia+L%3B+colore+Navy
&L_PAYMENTREQUEST_0_NUMBER0=0LLR7IQ-B0SIE+%28Product+%230LLR7IQ-B0SIE%29
&L_PAYMENTREQUEST_0_DESC0=160+g%2Fm%C2%B2%2C+100+%25+cotone+ring-spun%2C+pre-ristretto%2C+simple+jersey%2C+scollatura+arrotondata%2C+maniche+corte%2C+impunture+sulla+scollatura%2C+sul+bordo+delle+maniche+e+sulla+base%2C+cuciture+laterali.
&L_PAYMENTREQUEST_0_AMT0=1.90
&L_PAYMENTREQUEST_0_QTY0=1
&L_PAYMENTREQUEST_0_NAME1=T-shirt+ring-spun+attillata%3B+taglia+M%3B+colore+Dark+Heather
&L_PAYMENTREQUEST_0_NUMBER1=0LLR7IQ-2KEI1+%28Product+%230LLR7IQ-2KEI1%29
&L_PAYMENTREQUEST_0_DESC1=160+g%2Fm%C2%B2%2C+100+%25+cotone+ring-spun%2C+pre-ristretto%2C+simple+jersey%2C+scollatura+arrotondata%2C+maniche+corte%2C+impunture+sulla+scollatura%2C+sul+bordo+delle+maniche+e+sulla+base%2C+cuciture+laterali.
&L_PAYMENTREQUEST_0_AMT1=1.90
&L_PAYMENTREQUEST_0_QTY1=1
&L_PAYMENTREQUEST_0_NAME2=T-shirt+ring-spun+attillata%3B+taglia+S%3B+colore+White
&L_PAYMENTREQUEST_0_NUMBER2=0LLR7IQ-TFOHI+%28Product+%230LLR7IQ-TFOHI%29
&L_PAYMENTREQUEST_0_DESC2=160+g%2Fm%C2%B2%2C+100+%25+cotone+ring-spun%2C+pre-ristretto%2C+simple+jersey%2C+scollatura+arrotondata%2C+maniche+corte%2C+impunture+sulla+scollatura%2C+sul+bordo+delle+maniche+e+sulla+base%2C+cuciture+laterali.
&L_PAYMENTREQUEST_0_AMT2=1.59
&L_PAYMENTREQUEST_0_QTY2=1
&ITEMAMT=5.39
&TAXAMT=1.08
&SHIPPINGAMT=0.00
&AMT=6.47
&ALLOWNOTE=1
&USER=XXXXXXXX
&PWD=XXXXXXXX
&SIGNATURE=XXXXXXXX
&METHOD=SetExpressCheckout
&VERSION=53.0
I forward the user to here, which is the token Paypal gives me back in response to my first request.
The problem is that, despite the successful request with all prices set in, I have an empty Paypal review page, with absolutely no prices into.
What am I missing?
Attack of the poor API docs! Paypal sure tried hard, but they fall short. I've fought this API and won! :)
Change these values in what you already have... let me know if it takes care of the problem
&PAYMENTREQUEST_0_PAYMENTACTION=Sale [[ <--- payment action ]]
&PAYMENTREQUEST_0_CURRENCYCODE=EUR [[<-- currency code]]
&PAYMENTREQUEST_0_ITEMAMT=5.39 [[<---- subtotal here]]
&PAYMENTREQUEST_0_TAXAMT=1.08 [[<---- tax here]]
&PAYMENTREQUEST_0_SHIPPINGAMT=0.00 [[<---- shipping here]]
&PAYMENTREQUEST_0_AMT=6.47 [[<---- grand total here]]
&PAYMENTREQUEST_0_ALLOWNOTE=1
This one bugged me as well for a couple of days.
Using the Java SDK from developer.paypal.com (as of 2008), I finally came across a new version of the SDK (Nov 2011) at https://www.x.com/developers/paypal/documentation-tools/sdk#3
Using the new SDK (in particular, the updated paypal_base.jar) however did NOT yet solve my issue.
You have to figure out the correct API Version String to make it run. With version "51.0" (as in some of my example code), the call failed. As with version "78.0", the new SDK did the job.
Cheerio....
In addition to the other comments here, be sure to use the undocumented "useraction" option when you redirect to PayPal after getting the response from SetExpressCheckout:
?cmd=_express-checkout&useraction=commit&token=the-returned-token
(the link below no longer works)
Here's the PayPal forum reference to this parameter

Categories