Using the primary payment method token

This scenario is used to assist integrators that only allow one payment method token associated with the customer.

Ezypay allows a customer to be associated with multiple payment method tokens at a time. In order to identify the main payment method token used, retrieval of the primary payment method token is important.

1. Create a primary payment method token

This step is assuming that:

  1. The customer has already been created (https://developer.ezypay.com/reference#testinput)
  2. The payment method token has been created (Using Ezypay's Payment Method Creation Page).

🚧

NOTE

Remember to always have the "primary" field set to true. This will always replace the primary payment method with the last created payment method token.

Once create submitted, the "primary" flag will be set to true for the newly connected payment method token.

[POST] https://api-sandbox.ezypay.com/v2/billing/customers/{{customerId}}/paymentmethods

{  
   "paymentMethodToken":"{{Payment_Method_Token}}",
   "primary":true
}
{
    "paymentMethodToken": "{{Payment_Method_Token}}",
    "customerId": "{{customerId}}",
    "type": "CARD",
    "bank": null,
    "card": {
        "first6": "455617",
        "last4": "5153",
        "accountHolderName": "TestPayment123",
        "type": "VISA",
        "expiryMonth": "10",
        "expiryYear": "25"
    },
    "invalidReason": null,
    "lastUsedOn": null,
    "valid": true,
    "primary": true
}

2. Get the primary payment method token

[GET] https://api-sandbox.ezypay.com/v2/billing/customers/{{CustomerId}}/paymentmethods/primary

{  
   "paymentMethodToken":"{{payment_method_token}}",
   "customerId":"37a2e1dd-c1d9-4fda-a077-6908877aa84c",
   "type":"CARD",
   "bank":null,
   "card":{  
      "first6":"455617",
      "last4":"5153",
      "accountHolderName":"TestPayment123",
      "type":"VISA",
      "expiryMonth":"10",
      "expiryYear":"25"
   },
   "invalidReason":null,
   "lastUsedOn":null,
   "valid":true,
   "primary":true
}

πŸ“˜

NOTE

If an invoice is created without the payment method token being provided, the primary payment method token will be used.