This Choreo verifies that a PayPal payment from the Adaptive Payments API has been successfully completed. The payment verification process is described here.
There are two types of proof of payments that can be received using the PayPal iOS SDK:
- An Adaptive Payments proof of payment that is a result of a user paying with PayPal.
- A REST API proof of payment that is a result of a user paying with a credit card.
This Choreo handles Adaptive Payments proof of payments.
Here is a sample of a Adaptive Payments proof of payment from the PayPal SDK:
{
"proof_of_payment": {
"adaptive_payment": {
"pay_key": "AP-9HM19836JM743825P",
"payment_exec_status": "COMPLETED",
"timestamp": "2013-02-20T00:26:25Z",
"app_id": "APP-91B933855X481767M"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "2.50",
"currency_code": "USD"
},
"client": {
"platform": "iOS",
"paypal_sdk_version": "1.0.0",
"environment": "live",
"product_name": "PayPal iOS SDK"
}
}
You can pass this JSON to the VerifyPayPalPayment Choreo, and the Choreo will retrieve details for the payment from the PayPal Adaptive Payment API. After retriving payment details, the Choreo verifies the appropriate verification fields and returns the string "verified" in the VerificationStatus output if the payment is complete and matches the expectations. If the payment details do not indicate that the payment flow is complete, the string "unverified" is returned in the VerificationStatus output. When a payment is "unverified", the FailureDescription will contain a JSON dictionary listing the reasons.
Here is an example list of acceptable inputs:
AppID: APP-80W284485P519543T (Note: this is the AppID for the PayPal sandbox)
Password: {YOUR PAYPAL CLASSIC API PASSWORD}
Signature: {YOUR PAYPAL CLASSIC API SIGNATURE}
Username: {YOUR PAYPAL CLASSIC API USERNAME}
UseSandbox: 1
ProofOfPayment:
{
"proof_of_payment": {
"adaptive_payment": {
"pay_key": "AP-9HM19836JM743825P",
"payment_exec_status": "COMPLETED",
"timestamp": "2013-02-20T00:26:25Z",
"app_id": "APP-91B933855X481767M"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "2.50",
"currency_code": "USD"
},
"client": {
"platform": "iOS",
"paypal_sdk_version": "1.0.0",
"environment": "live",
"product_name": "PayPal iOS SDK"
}
}
In the event that the payment details indicate that the payment is not complete or that an expected value is different, the JSON returned in the FailureDescription output might look something like this:
{
"total": "The expected total is: 4.00. The total retrieved was: 2.00.",
"saleState": "The expected sale state is: completed. The sale state received was: null.",
"paymentState": "The expected payment state is: approved. The payment state received was: created."
}