Skip to main content

Payment flow for E-wallets (online payment methods)

Payment flow for E-wallets (online payment methods)

Last updated: 11-Jul-2022
Rate this article:

Overview

E-wallets are online payment methods where the order is registered by 2Checkout, but the shopper has to reach a 3rd party's website in order to authenticate and finalize the payment. PayPal is one of the most used E-wallet solutions that dominate the eCommerce world, but other local players, especially in Asian countries, are starting to gain market share.

The following payment methods are supported for the E-wallet (online payment methods) flow PayPal, Alipay, Webmoney, WeChat, Giropay, iDeal.

Availability

Available to all 2Checkout accounts.

PayPal

Payment method Object structure

Field name Type Required/Optional Description

ReturnURL

String

Mandatory

The return URL is the page on your website to which PayPal redirects your buyer's browser after the buyer logs in to PayPal and approves the payment. Typically, this is a secure page (https://...) on your site.

Email

String

Optional

Email address customers use for their PayPal account.

Request example

{
   "Language":"en",
   "Country":"US",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"USD",
   "MachineId":"123456789",
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"US",
      "State":"New York",
      "City":"New York",
      "Address1":"Example Street",
      "Zip":"10005",
      "Email":"customer@email.com"
   },
   "PaymentDetails":{
      "Type":"PAYPAL",
      "Currency":"USD",
      "PaymentMethod":{
         "RecurringEnabled":false,
         "ReturnURL":"http:\/\/mywebsite.com\/order\/",
         "Email":"customer@email.com"
      }
   }
}

Redirecting shoppers to PayPal

If the order is placed successfully, the 2Checkout API responds with the complete order information. Inside the PaymentDetails node, you will find the PaymentMethod node that contains the RedirectURL

The shopper needs to be redirected to this URL that takes them to the PayPal website to finalize the payment. Once the payment is finalized, shoppers are redirected back to the ReturnURL

PayPal Express - Alternative Flow

In some checkout flows, the user experience might require some details filled in by the shopper on PayPal's side. In order to streamline the checkout experience, this information can be used when placing orders by using the PayPal Express payment method. 

These are the required steps for the PayPal Express flow:

  1. First, you must retrieve the RedirectURL from PayPal by calling the getPayPalExpressCheckoutRedirectURL method for JSON-RPC and SOAP, or by making a PUT request to /paymentmethods/PAYPAL_EXPRESS/redirecturl/ on REST.
  2. The body of the request must contain the order object with, at a minimum, the product information as well as the payment details: the customer's email address and a ReturnURLthe page on the shop's side where the shopper is redirected after the flow is completed on the PayPal's side. 
  3. The ReturnURL parses the response that PayPal sends in order to fetch the needed information and finalize the payment. 
  4. The getPayPalExpressCheckoutRedirectURL method will return a URL where the shopper needs to be redirected in order to complete the payment.
  5. Once the shopper completes the payment, PayPal returns the shopper to the URL provided in the ReturnURL. The information provided by the shopper on PayPal's side is available in the GET parameters of the ReturnURL (all information is MIME base64 encoded):
  • billing details (under the billingDetails key)
  • delivery details (under the deliveryDetails key)
  • a token in the URL.

6. If the shopper cancels their payment, then the cancel key will be returned in the URL. 

7. The information provided in the billing and delivery details must be filled in the order object. 

The payment method object will look like this:

Field name Type Required/Optional Description

Email

String

Required

The email of the customer, as used when triggering the getPayPalExpressCheckoutRedirectURL method.

Token

String

Required

The token returned by PayPal.

ReturnURL

String

Required

The return URL on the shop side that will handle successful orders.

CancelURL

String

Required

The return URL on the shop side that will handle canceled orders.

In JSON, this looks like:

    "PaymentDetails": {
        "Type": "PAYPAL_EXPRESS",
        "Currency": "EUR",
        "CustomerIP": "91.220.121.21",
        "PaymentMethod": {
            "Email": "customer@email.com",
            "Token": "EC-470284976K7901234",
            "ReturnURL": "http://shop.com/place_order_api_json_paypal_express_response.php",
            "CancelURL": "http://shop.com/place_order_api_json_paypal_express_response.php?cancel=true"
        }
    }

Alipay

Payment method object structure

Alipay does not require any mandatory fields to be sent in the PaymentDetails node of the request.

Request example

{
   "Language":"en",
   "Country":"HK",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"CNY",
   "MachineId":"123456789",
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"HK",
      "State":"Hong Kong",
      "City":"Hong Kong",
      "Address1":"Example Street",
      "Zip":"999077",
      "Email":"example@email.com"
   },
   "PaymentDetails":{
      "Type":"ALIPAY",
      "Currency":"CNY",
      "PaymentMethod":{
         "RecurringEnabled":false
      }
   }
}

Redirecting shoppers to Alipay

If the order is placed successfully, the 2Checkout API responds with the complete order information. Inside the PaymentDetails node, you will find the PaymentMethod/Redirect node that contains the URL

The shopper needs to be redirected to this URL. This takes them to the Alipay website, where they can finalize the payment. 

Webmoney

Payment method object structure

Webmoney does not require any mandatory fields to be sent in the PaymentDetails node of the request.

Request example

{
   "Language":"en",
   "Country":"RU",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"EUR",
   "MachineId":"123456789",
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"RU",
      "State":"Central",
      "City":"Moscow",
      "Address1":"Example Street",
      "Zip":"105005",
      "Email":"example@email.com"
   },
   "PaymentDetails":{
      "Type":"WEBMONEY",
      "Currency":"EUR",
      "PaymentMethod":{
         "RecurringEnabled":false
      }
   }
}

Redirecting shoppers to Webmoney

If the order is placed successfully, the 2Checkout API responds with the complete order information. Inside the PaymentDetails node, you will find the PaymentMethod/Redirect node that contains the URL, Method, and Params node. 

The shopper needs to be redirected to this URL, using the Method mentioned in the API response. Additionally, the parameters in the Params node need to be sent as key-value pairs in the body of the request.

This will take shoppers to the Webmoney website, where they can finalize the payment. 

WeChat

Payment method object structure

Field name Type Required/Optional Description

ReturnURL 

String

Required

The URL address to which customers are redirected after the payment is completed successfully.

CancelURL 

String

Required

The URL address to which customers are redirected after the payment is completed unsuccessfully.

Request example

{
   "Language":"en",
   "Country":"CN",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"USD",
   "MachineId":"123456789",
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"CN",
      "State":"Beijing",
      "City":"Beijing",
      "Address1":"Example Street",
      "Zip":"102629",
      "Email":"example@email.com"
   },
   "PaymentDetails":{
      "Type":"WE_CHAT_PAY",
      "Currency":"USD",
      "PaymentMethod":{
         "RecurringEnabled":false,
         "ReturnURL":"http:\/\/yourreturnurl.com",
         "CancelURL":"http:\/\/yourcancelurl.com"
      }
   }
}

Redirecting shoppers to WeChat

If the order is placed successfully, the 2Checkout API responds with the complete order information. Inside the PaymentDetails node, you will find the PaymentMethod/Authorize node that contains the Href, Method, and Params node. 

The shopper needs to be redirected to this Href, using the Method mentioned in the API response. Additionally, the parameters in the Params node need to be sent as key-value pairs in the request.

This takes shoppers to the WeChat website, where they can finalize the payment. 

Giropay

Payment method object structure

Giropay does not require any mandatory fields to be sent in the Payment Details node of the request.

Request example

{
   "RefNo":null,
   "Currency":"EUR",
   "Country":"DE",
   "Language":"EN",
   "CustomerIP":"10.5.22.197",
   "ExternalReference":"REST_API_AVANGTEAS01",
   "Source":null,
   "AffiliateId":null,
   "CustomerReference":null,
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"John",
      "LastName":"Doe",
      "CountryCode":"DE",
      "State":"Berlin",
      "City":"Berlin",
      "Address1":"Test street ",
      "Zip":"10247",
      "Email":"john.doe@2checkout.com",
      "Phone":"0123456789"
   },
   "PaymentDetails":{
      "Type":"GIROPAY",
      "Currency":"EUR",
      "CustomerIP":"10.5.22.197",
      "PaymentMethod":{
         "RecurringEnabled":false
      }
   }
}

Redirecting shoppers to Giropay

If the order is placed successfully, the 2Checkout API responds with the complete order information. Inside the PaymentDetails node, you will find the PaymentMethod/Redirect node that contains the URL, Method, and Params node. 

The shopper needs to be redirected to this URL, using the Method mentioned in the API response. Additionally, the parameters in the Params node need to be sent as key-value pairs in the request.

This takes shoppers to the Giropay website, where they can finalize the payment. 

iDeal

iDeal is a standardized online banking-based payment method tailored to users in the Netherlands. iDEAL supports online payments via secure online transfers directly between bank accounts. 

To place an order with iDeal, the shopper needs to select the bank that they use. The full list of supported banks can be queried via API by calling the getIdealIssuerBanks method (SOAP and JSON-RPC) or making a GET request /paymentmethods​/IDEAL​/issuerbanks​/ on REST.

The output of this API call is the list of supported banks, as code (to be used when placing the order), and the user-readable name of the bank.

[
   {
      "Code":"ABNANL2A+ABN",
      "Name":"ABN AMRO"
   },
   {
      "Code":"RABONL2U+RAB",
      "Name":"Rabobank"
   },
   {
      "Code":"INGBNL2A+ING",
      "Name":"ING"
   }
]

Payment method Object structure

Field name Type Required/Optional Description

BankCode

String

Required

The bank code as returned by the getIdealIssuerBanks API call.

ReturnURL 

String

Required

The URL address to which customers are redirected after the payment is completed successfully.

CancelURL 

String

Required

The URL address to which customers are redirected after the payment is completed unsuccessfully.

BankCode

String

Required

The bank code as returned by the getIdealIssuerBanks API call.

 Request example

{
   "Language":"en",
   "Country":"NL",
   "CustomerIP":"10.10.10.10",
   "Source":"Website",
   "ExternalCustomerReference":"externalCustomerId",
   "Currency":"EUR",
   "MachineId":"123456789",
   "Items":[
      {
         "Code":"DD996A4DB3",
         "Quantity":1
      }
   ],
   "BillingDetails":{
      "FirstName":"Customer First Name",
      "LastName":"Customer Last Name",
      "CountryCode":"NL",
      "State":"North Holand",
      "City":"Amsterdam",
      "Address1":"Example Street",
      "Zip":"1183",
      "Email":"example@email.com"
   },
   "PaymentDetails":{
      "Type":"IDEAL",
      "Currency":"EUR",
      "PaymentMethod":{
         "ReturnURL":"http:\/\/yourreturnurl.com",
         "CancelURL":"http:\/\/yourcancelurl.com",
         "BankCode":"RABONL2U+RAB"
      }
   }
}

Redirecting shoppers to finalize the payment

Once the order has successfully been placed, in the response in the PaymentDetails/PaymentMethod/Authorize node, you have the information needed to compose the URL where the shopper needs to finalize the payment.

The shopper needs to reach the Href via the Method HTTP method, with the key-values in the Params in the request parameters.

 "PaymentDetails":{
      "Type":"IDEAL",
      "Currency":"eur",
      "PaymentMethod":{
         "Authorize":{
            "Href":"https:\/\/api.avangate.com\/6.0\/scripts\/ideal\/authorize",
            "Method":"GET",
            "Params":{
               "avng8apitoken":"ukaiuljobm84jmt3"
            },
            "AvangateId":null
         },
         "ReturnURL":"http:\/\/yourreturnurl.com",
         "CancelURL":"http:\/\/yourcancelurl.com",
         "BankCode":"RABONL2U+RAB",
         "RecurringEnabled":false
      },
      "CustomerIP":"5.12.32.22"
   },

Once the shopper has finalized the payment, the order will be marked with 'status = Complete'.

Integration test cases

  1. Build a request in order to place a new order, with all the relevant information. Make sure that when the order is sent in the API, the response contains an order object (order was placed successfully).
  2. Make sure that you handle the redirect to the 3rd party site.
  3. If you have any additional webhook integrations, make sure that the webhooks are correctly configured and that the notifications are received and processed successfully. 

 

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo