Skip to content

Instantly share code, notes, and snippets.

@tomwhipple
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomwhipple/62075b4eb9abca1129cf to your computer and use it in GitHub Desktop.
Save tomwhipple/62075b4eb9abca1129cf to your computer and use it in GitHub Desktop.
Verify a PayPal immediate payment in sandbox

MSDKv2 Payment Verification

Generated 2014-07-28 09:03:10.408600

PayPal Payment (v2)

Make a single PayPal payment (checkout) with MSDKv2

Client Credentials

(confidential client, e.g. merchant server <-> PayPal server)

Headers

Content-Type: application/x-www-form-urlencoded
Authorization: Basic QWRoVWNSQ29Lc3hXa25UTGpqSE9Zd2ZwbHN**********************************TElTSXppakdLSFowUWlxQUpXTFcxam1tOHNib3RTWGVxdWlrdm9XVmkzTg==

Body

grant_type=client_credentials
response_type=token

curl

curl -v -k -X POST 'https://api.sandbox.paypal.com/v1/oauth2/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic QWRoVWNSQ29Lc3hXa25UTGpqSE9Zd2ZwbHNlQzNKYjd**********************************ROkVFNTdDaENXQnRVSkxfMDlFTElTSXppakdLSFowUWlxQUpXTFcxam1tOHNib3RTWGVxdWlrdm9XVmkzTg==" \
-d 'grant_type=client_credentials&response_type=token&return_authn_schemes=true' 

Response: 200

Headers

content-length: 399
server_info: identitysecuretokenserv:v1.oauth2.token&CalThreadId=136&TopLevelTxnStartTime=1477db61471&Host=slcsbidensectoken502.slc.paypal.com&pid=20717
server: Apache-Coyote/1.1
date: Mon, 28 Jul 2014 16:03:10 GMT
paypal-debug-id: 1fbf88c54c73d
proxy_server_info: host=slcsbjava3.slc.paypal.com;threadId=240
content-type: application/json;charset=utf-8

Body

{
    "access_token": "A015RpzaPypgT4J6I3dIxycco6LQW4XaRaGn1eFrVJ0jdlY", 
    "expires_in": 28800, 
    "app_id": "APP-80W284485P519543T", 
    "token_type": "Bearer", 
    "scope": "openid https://uri.paypal.com/services/invoicing https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card/.* https://api.paypal.com/v1/vault/credit-card"
}

<Response [200]> client_credentials took 0:00:00.545576 time to finish

Verify Payment

(confidential client, e.g. merchant server <-> PayPal server)

Headers

Content-Type: application/json
Authorization: Bearer A015RpzaPypgT4J6I3dIxycco6LQW4XaRaGn1eFrVJ0jdlY

Body


curl

curl -v -k -X GET 'https://api.sandbox.paypal.com/v1/payments/payment/PAY-0PD99352VN0966130KPLG66Q' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer A015RpzaPypgT4J6I3dIxycco6LQW4XaRaGn1eFrVJ0jdlY" \
 

Response: 200

Headers

content-length: 1175
content-language: en_us
server_info: paymentsplatformserv:v1.payments.payment&CalThreadId=1931&TopLevelTxnStartTime=1477db61654&Host=slcsbjm3.slc.paypal.com&pid=16961
server: Apache-Coyote/1.1
date: Mon, 28 Jul 2014 16:03:10 GMT
paypal-debug-id: 52032f144c6a7
proxy_server_info: host=slcsbjava3.slc.paypal.com;threadId=240
content-type: application/json

Body

{
    "update_time": "2014-07-28T15:42:53Z", 
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0PD99352VN0966130KPLG66Q", 
            "method": "GET", 
            "rel": "self"
        }
    ], 
    "payer": {
        "payment_method": "paypal", 
        "status": "VERIFIED", 
        "payer_info": {
            "first_name": "tom", 
            "last_name": "whipple", 
            "email": "twhipple-consumer@paypal.com", 
            "payer_id": "CBQG8NAHWQ3GE"
        }
    }, 
    "transactions": [
        {
            "related_resources": [
                {
                    "sale": {
                        "update_time": "2014-07-28T15:42:53Z", 
                        "links": [
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/10768459GF447151H", 
                                "method": "GET", 
                                "rel": "self"
                            }, 
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/10768459GF447151H/refund", 
                                "method": "POST", 
                                "rel": "refund"
                            }, 
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0PD99352VN0966130KPLG66Q", 
                                "method": "GET", 
                                "rel": "parent_payment"
                            }
                        ], 
                        "state": "completed", 
                        "id": "10768459GF447151H", 
                        "amount": {
                            "currency": "USD", 
                            "total": "1.03"
                        }, 
                        "create_time": "2014-07-28T15:42:50Z", 
                        "parent_payment": "PAY-0PD99352VN0966130KPLG66Q"
                    }
                }
            ], 
            "amount": {
                "currency": "USD", 
                "total": "1.03", 
                "details": {
                    "subtotal": "1.03"
                }
            }, 
            "description": "A+ #1 sauce"
        }
    ], 
    "state": "approved", 
    "create_time": "2014-07-28T15:42:50Z", 
    "intent": "sale", 
    "id": "PAY-0PD99352VN0966130KPLG66Q"
}

<Response [200]> verify_payment took 0:00:00.356275 time to finish

PASS: v2 PayPal/wallet main took 0:00:00.908768 time to finish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment