This Choreo verifies that a payment has been successfully completed. The payment verification process is described here.
There are two types of proof of payment 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 both types of proof of payments.
Here is a sample of an Adaptive Payment proof of payment from the PayPal SDK:
{
"proof_of_payment": {
"adaptive_payment": {
"pay_key": "AP-70M68096ML426802W",
"payment_exec_status": "COMPLETED",
"timestamp": "2013-02-20T00:26:25Z",
"app_id": "APP-91B933855X481767M"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "9.95",
"currency_code": "USD"
},
"client": {
"platform": "iOS",
"paypal_sdk_version": "1.0.0",
"environment": "live",
"product_name": "PayPal iOS SDK"
}
}
Here is a sample of a REST API proof of payment from the PayPal SDK:
{
"proof_of_payment": {
"rest_api": {
"state": "approved",
"payment_id": "API-PAYMENT-ID-1843"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "9.95",
"currency_code": "USD"
},
"client": {
"platform": "iOS",
"paypal_sdk_version": "1.0.0",
"environment": "live",
"product_name": "PayPal iOS SDK"
}
}
When receiving either of these proof of payments, you can pass this JSON to the VerifyAllPayments Choreo, and the Choreo will detect whether or not to make a request to the Adaptive Payments API or the REST API in order to retrieve details about the payment. 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 FailureDesccription 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)
ClientID: {YOUR PAYPAL REST API CLIENT ID}
ClientSecret: {YOUR PAYPAL REST API CLIENT SECRET}
Password: {YOUR PAYPAL CLASSIC API PASSWORD}
Signature: {YOUR PAYPAL CLASSIC API SIGNATURE}
Username: {YOUR PAYPAL CLASSIC API USERNAME }
UseSandbox: 1
ProofOfPayment:
{
"proof_of_payment": {
"rest_api": {
"state": "approved",
"payment_id": "API-PAYMENT-ID-1843"
}
},
"payment": {
"short_description": "Hipster t-shirt",
"amount": "9.95",
"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."
}