Step 1 - Available Payment Methods

Based on the One-Step Authorization example, let’s see how this would work with 2-Step Authorization.

Astrid goes to the webshop and puts all the items she wants into her cart, from the individual item pages. Then she clicks on the shopping cart icon.

On the shopping cart page, the merchant shows the items she’s buying, and asks her to fill in her name, email, national ID number, and address. (This is because Astrid is doing a checkout as a guest. If she was already a logged-in customer of the webshop, the info would be pre-filled.)

Astrid then clicks “Go to Checkout”. As the checkout page loads, the webshop sends a POST call to the PAYMENT-METHODS endpoint of the AfterPay eCom API. The call contains the customer’s details and the order item details.

Based on the provided information, AfterPay does a series of checks on this order (a credit/risk check on the customer, and a business logic check on the order size/contents). It then returns a list of available payment methods . The merchant can then give Astrid multiple options – the standard 14-day invoice, a Consolidated Invoice or Campaign Invoice if they are available, or Part Payment options (either a fixed-term scheme or a flexible monthly payment scheme).

The API response contains the names, taglines and logos of the payment methods. Your checkout page should incorporate these and display them to the customer. See our Display Guidelines for more.

The response contains the following information:

  • Checkout ID – the unique transaction ID for this checkout in the AfterPay system.
  • Outcome – whether AfterPay is willing to accept this order.
  • Customer – the customer details, as provided by the merchant.
  • Payment Methods – the details of the payment methods that AfterPay is willing to accept for this order. There will be one or more blocks, each consisting of:
    • Type – as per Payment Methods.
    • Title – the title of this payment method, as displayed to the customer.
    • Tag – the tagline (short description) of this payment method, as displayed to the customer.
    • Logo – the URL of the AfterPay logo, as displayed to the customer.
    • Account – if the type is Account, this block contains additional information about flexible monthly payments.
    • Campaigns – if the type is Invoice and campaign invoices are currently available, this block contains additional information about the campaign.
    • Direct Debit – if the type is Invoice and direct debit is configured, this block will read “true”.
      • You will need to collect the customer’s bank account information and pass it to AfterPay in the Capture call.
    • Installment – if the type is Installment, this block contains additional information about the fixed term payments.

If different types of invoices are available (e.g. regular 14-Day Invoice that must be paid via MyAfterPay.com, a 14-day Invoice with Direct Debit that is automatically paid from the customer’s bank account, and a Campaign Invoice), these will be separate blocks – even though they all have type=Invoice.

POST https://sandbox.afterpay.io/api/v3/checkout/payment-methods


{
  "customer": {
    "identificationNumber": "800119-3989",
    "salutation": "Mrs",
    "firstName": "Astrid",
    "lastName": "Svensson",
    "email": "astrid.svensson@example.com",
    "customerCategory": "Person",
    "address": {
      "street": "Kungsgatan",
      "streetNumber": "66",
      "postalCode": "11122",
      "postalPlace": "Stockholm",
      "countryCode": "SE"
    },
    "conversationLanguage": "EN"
  },
  "order": {
    "number": "afterpay4",
    "totalGrossAmount": 2085.0,
    "items": [
      {
        "productId": "0001-BLK-M",
        "description": "Leather jacket, Black, size M",
        "grossUnitPrice": 1000.0,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "imageUrl": "https://cdn.afterpay.io/dev-portal/images/black_leather_jacket.jpg",
        "lineNumber": 2
      },
      {
        "productId": "0001-BLK-S",
        "description": "Leather jacket, Black, size S",
        "grossUnitPrice": 1000.0,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "imageUrl": "https://cdn.afterpay.io/dev-portal/images/black_leather_jacket.jpg",
        "lineNumber": 1
      },
      {
        "productId": "0002-GRY-M",
        "description": "Socks, Grey, Size M",
        "grossUnitPrice": 10.0,
        "quantity": 5.0,
        "vatPercent": 20.0,
        "imageUrl": "https://cdn.afterpay.io/dev-portal/images/grey_socks.jpg",
        "lineNumber": 3
      },
      {
        "productId": "0004-BRN-M",
        "description": "Woolen hat, brown, Size M",
        "grossUnitPrice": 30.0,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "imageUrl": "http://cdn.afterpay.io/dev-portal/images/brown_wool_hat.jpg",
        "lineNumber": 4
      },
      {
        "productId": "SHIP",
        "description": "Shipping",
        "type": "ShippingFee",
        "grossUnitPrice": 5.0,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "lineNumber": 5
      }
    ]
  }
}

RESPONSE from the eCom API:


{
  "CheckoutId": "22ba05f7-be47-4a02-9dd0-0aeff24f5b5d",
  "Outcome": "Accepted",
  "Customer": {
    "CustomerNumber": "1150309557",
    "FirstName": "Astrid",
    "LastName": "Svensson",
    "AddressList": [
      {
        "Street": "Kungsgatan",
        "StreetNumber": "66",
        "PostalCode": "11122",
        "PostalPlace": "Stockholm",
        "CountryCode": "SE"
      }
    ]
  },
  "PaymentMethods": [
    {
      "Type": "Invoice",
      "Title": "14-Day Invoice",
      "Tag": "Pay after delivery, and only for what you keep!",
      "Logo": "https://cdn.myafterpay.com/logo/AfterPay_logo.svg"
    },
    {
      "Type": "Invoice",
      "Title": "14-Day Invoice with Direct Debit",
      "Tag": "Pay after delivery, and never miss a payment deadline!",
      "Logo": "https://cdn.myafterpay.com/logo/AfterPay_logo.svg",
      "DirectDebit": {
        "Available": true
      }
    }
  ]
}