API: Understanding state of the sale transaction

sachin10190
Contributor
Contributor

Hi,

 

I am using paypal-php-sdk. When creating a Sale transaction, i understand that when related_resources -> sale -> state = "Completed", then it means the payment is successful.

 

I just want to get clarification on the rest of possible values for this field

"completedpartially_refundedpendingrefundeddenied"

 

Can i rely on "denied" state for checking if the transaction has failed.

Can i rely on "pending" state for checking if the transaction is under review from paypal and thus pending.

 

Please check the documentation for this field

@https://developer.paypal.com/docs/api/payments/v1/#definition-sale

 

Also, i would like to ask if using API V1 is safe and when in the future it will be removed

Thank you in advance

Login to Me Too
3 REPLIES 3

MTS_Stefan
Moderator
Moderator

Hi Sachin,

 

The states are depending on the method that provided them.

State is part of Payment Details, Refunds, Authorizations etc.

As of that, you need to look up where you receive them, to know what they really stand for.

here some examples: 

https://developer.paypal.com/docs/api/payments/v1/#payment_get

https://developer.paypal.com/docs/api/payments/v1/#authorization_get

https://developer.paypal.com/docs/api/payments/v1/#authorization_capture

https://developer.paypal.com/docs/api/payments/v1/#refund_get

 

I hope that helps.

Kind Regards,

Stefan

Login to Me Too

sachin10190
Contributor
Contributor

Hi Stefan,

 

Thank you for your quick response

 

My query is related to "Create Payment" API

https://developer.paypal.com/docs/api/payments/v1/#payment_create

 

As a response we get "transactions" object

https://developer.paypal.com/docs/api/payments/v1/#definition-transaction

 

In transactions we have "related_resources" object

https://developer.paypal.com/docs/api/payments/v1/#definition-related_resources

 

In related_resources we have "sale" object

https://developer.paypal.com/docs/api/payments/v1/#definition-sale

 

and finally in sale object we have "state" field, whose possible values are 

Possible values: completed, partially_refunded, pending, refunded, denied.

 

I am relying on "completed" value to check if the "sale" has been successful, similarly can we safely say that "pending means under review" and "denied means transaction failed and money wasn't deducted from payer account".

Can you please confirm this, and also the query regarding API V1 depreciation timeline

thank you for the help so far

 

Login to Me Too

Marinario
New Community Member

I'm just replying in order to help someone struggling with this issue while still using PHP SDK or API v1. One of the reasons why related_resources -> sale -> state may still be pending is because the order should be approved manually by the buyer in the buyer sandbox dashboard. So you have to change that setting and make Review Payment > Off. Actually you can find this setting when you login with developer account, list you app/sandboxes and select the one you want to change the settings. There should be a setting called 'Review Payment' and turn that off. In my case the setting was already off, I just have to turn it on and turn it off again and voila after executing the payment the related_resources -> sale -> state became 'completed'.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.