Skip to main content
Rate this article:

This tutorial takes you through the steps required to do your first transaction through the PayPal Ecomm API with Verifone. At the end of the tutorial you will have basic understanding of how the PayPal Ecomm API works and how to perform transactions.

Step 1: Set up

Get your access token here!

Before making a transaction, you need:

  • PayPal Sandbox account 
  • Valid JWT Token
  • The Payment Provider Contract id. This is created as part of on-boarding merchant into Verifone via the Common Portal.

Read more about managed path or connected path integration available with PayPal.

Step 2: Creating a transaction

Make a POST request to /transactions endpoint. Here is an example of a payload:

{
    "intent": "AUTHORIZE",
    "amount": {
    	"value": 2700,
    	"currencyCode": "USD"
    },  
    "context": {
    	"paymentProviderContract": "YOUR_PAYMENT_PROVIDER_CONTRACT"
    },
    "customer": {
        "email": "yourEmail@personal.example.com",
        "payerId": "WDJJHEBZ4X2LY",
        "phoneNumber": {
            "phoneType": "MOBILE",
            "value": "64646464"
        },
        "birthDate": "2000-01-31",
            "identification": {
            "taxIdentificationNumber": "123456",
            "taxIdentificationType": "BR_CNPJ"
        },
        "address": {
            "country": "IN",
            "postalCode": "570023",
            "countrySubdivision": "IN-MH",
            "city": "yyy",
            "addressLine1": "add1",
            "addressLine2": "add2"
        },
        "firstName": "James",
        "lastName": "Smith"
    },
    "applicationContext": {
        "brandName": "MAHENDRA",
        "locale": "he-IL",
        "landingPage": "BILLING",
        "returnUrl": "http://example.com/success",
        "cancelUrl": "http://example.com/failure"
    },
    "shipping": {
        "address": {
            "country": "IN",
            "postalCode": "91",
            "countrySubdivision": "IN-MH",
            "city": "mysore",
            "addressLine1": "walstreet",
            "addressLine2": "forcircle"
        },
        "fullName": "JamesSmith"
    },
    "items": [
        {
            "name": "Mac Laptop",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "Dell Laptop",
            "sku": "123",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Phone",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "10",
            "description": "Apple phone",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Dell XPS 9310 13.4 FHD Display Thin & Light 11th Gen Laptop (i5-1135G7 / 8 GB / 512 SSD / Integrated Graphics / 1Yr Premium",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "groceries",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Samsung 6.5 kg Fully-Automatic Top Loading Washing Machine (WA65A4002VS/TL, Imperial Silver, Center Jet Technology)",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "product",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        }
    ],
    "dynamicDescriptor": "Paypal order DD123",
    "merchantReference": "DD123-reference",
    "invoiceNumber": "INV12357",
    "detailedAmount": {
        "discount": {
            "currencyCode": "USD",
            "value": 100
        },
        "shippingDiscount": {
            "currencyCode": "USD",
            "value": 100
        },
        "insurance": {
            "currencyCode": "USD",
            "value": 100
        },  
        "handling": {
            "currencyCode": "USD",
            "value": 100
        },
        "shipping": {
            "currencyCode": "USD",
            "value": 100
        }
    }
}

Example response:

{
   "id": "27241ae8-e72a-4586-9ef2-78dcb7a0ad9f",
   "orderId": "4DD655383X489915V",
   "createdAt": "2021-02-04T17:23:44Z",
   "status": "INITIATED",
   "approvalUrl": "https://www.sandbox.paypal.com/checkoutnow?token=4DD655383X489915V"
}

For details about the API and the request fields, please review the Create Transaction API.

Step 3: Approving the transaction

Open the approvalUrl link  from the previous API response, in the browser to approve the transaction. This would open the PayPal portal and would show the login page. Login using your PayPal buyer credentials and after reviewing the transaction detail, approve the transaction. After the approval, you would be redirected to the returnUrl that was passed in the applicationContext while creating the transaction. Also, if you cancel the approval flow in between, then you would be redirected to the cancelUrl.

 

Step 4: Authorize the transaction

Make a POST request to /transactions/:id/authorize for authorizing a transaction.

Note: This step is only required if the intent is to authorize a transaction. If the intent is to capture a transaction, please skip this step.

The ID parameter in the URL is the id from the response of the create transaction API call.

Step 5: Capture a payment

Make a POST request to /transactions/:id/capture to capture a transaction payment. Use id field from Step 2 as request parameter.

If you want to capture the full transaction, then there is no need to send the amount in the request payload, instead a null in the request body is to be sent.

However, if you want to capture a partial amount of the transaction, the you can send the amount object in the request payload as shown below:

 {
   "amount": {
       "value": 50,
       "currencyCode": "USD"
   }
}

 

 

Rate this article:
Logo of Verifone