One-Step Authorization using Flex Payment

The easiest and most convenient way to approve a payment is to use the authorize endpoint.

Merchants can provide shoppers with a more flexible payment option at checkout by allowing them to control the amount they are willing to pay per month, which means there is no set maturity. However, shoppers are obliged to pay a monthly minimum as defined by AfterPay. Shoppers can alter the amount they are willing to pay every month in AfterPay’s customer portal. Additional orders can be added at any time as long as the amount does not exceed the credit limit set by AfterPay.
For more detailed information about this payment type, visit the AfterPay Basics page.


NOTE! This use-case is meant for merchants who have made a contract with AfterPay and use prearranged payment options. If you want to present the available payment options for a specific customer first, use the two-step authorize use-case.


Preconditions

We have a customer, who is shopping the web for two black tablets and one black music player.
The customer creates an order and enters his personal data. He add adds two black tablets (400 euros each) and one black music player (200 euros) to cart and proceeds to authorize.

  • Order Items and Proceed
  • Authorize Request

Step 1 - Authorize Payment

Step 1.1 - Creating an AuthorizePaymentRequest

The merchant gathers customer and order information into an AuthorizePaymentRequest. Then, sends it to Authorize endpoint for validation.

NOTE! The merchant has chosen the payment method (Account) for the customer.


Important variables in this request

payment
object
required
type
enum
required

The payment object with the payment type is always required.

profileNo
number
required

In accountProduct object, account profile number is always required.

customer
object
required
identificationNumber
string
required

Since this is an One-Step Authorize, the customer object with identificationNumber and postalCode must be defined. Otherwise, AfterPay couldn't evaluate customer's eligibility for credit.

postalCode
number
required

In address object, postal code is always required.

order
object
required

Since this is an One-Step Authorize, the order object must be defined. Otherwise, it would be impossible to manage refunds/voids for the customer later.
Some important fields for Order object to note:

  • order number, which is specified by the merchant
  • totalGrossAmount, which has to match the SUM of the individual items (grossUnitPrice * quantity)
  • totalNetAmount of the order
  • OrderItem and OrderRisk objects

NOTE! If the provided address doesn't match with the address that was returned in the response, then the merchant has to update the address. Otherwise, AfterPay will not take any risk for the transaction.

For more detailed information about this request, visit the Payment's API Documentation.

{
  "payment": {
    "type": "Account",
    "account": {
      "profileNo": 1
    }
  },
  "customer": {
    "customerNumber": "507885681",
    "identificationNumber": "10114000294",
    "firstName": "Jan",
    "lastName": "Hansen",
    "email": "jan.hansen@example.com",
    "customerCategory": "Person",
    "address": {
      "street": "Kongens gate 2",
      "postalCode": "0153",
      "postalPlace": "Oslo",
      "countryCode": "NO"
    }
  },
  "order": {
    "number": "ORDER000001",
    "totalNetAmount": 750.00,
    "totalGrossAmount": 1000.00,
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 300.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 25.0,
        "vatAmount": 100.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "1",
        "description": "MusicPlayer Black",
        "netUnitPrice": 150.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 25.00,
        "vatAmount": 50.00,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    
        

{
  "payment": {
    "type": "Account",
    "account": {
      "profileNo": 1
    }
  },
  "customer": {
    "customerNumber": "507885683",
    "identificationNumber": "080470-0247",
    "firstName": "Antti",
    "lastName": "Virtanen",
    "email": "antti.virtanen@example.com",
    "birthDate": "1989-11-20T00:00:00Z",
    "customerCategory": "Person",
    "address": {
      "street": "Kaisaniemenkatu 13A",
      "postalCode": "00101",
      "postalPlace": "Helsinki",
      "countryCode": "FI"
    }
  },
  "order": {
    "number": "ORDER00001",
    "totalNetAmount": 760.00,
    "totalGrossAmount": 1000.00,
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 304.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 24.0,
        "vatAmount": 96.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "1",
        "description": "MusicPlayer Black",
        "netUnitPrice": 152.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 24.00,
        "vatAmount": 48.00,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    
        

{
  "payment": {
    "type": "Account",
    "account": {
      "profileNo": 1
    }
  },
  "customer": {
    "customerNumber": "507885684",
    "identificationNumber": "2610841349",
    "firstName": "William",
    "lastName": "Jensen",
    "email": "william.jensen@example.com",
    "birthDate": "1984-10-26T00:00:00Z",
    "customerCategory": "Person",
    "address": {
      "street": "Østbanegade",
      "streetNumber": "55",
      "postalCode": "2100",
      "postalPlace": "Kopenhagen",
      "countryCode": "DK"
    }
  },
  "order": {
    "number": "ORDER000001",
    "totalNetAmount": 750.00,
    "totalGrossAmount": 1000.00,
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 300.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 25.0,
        "vatAmount": 100.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 150.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 25.00,
        "vatAmount": 50.00,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    
        

{
  "payment": {
    "type": "Account",
    "account": {
      "profileNo": 1
    }
  },
  "customer": {
    "customerNumber": "507885682",
    "identificationNumber": "6103213499",
    "firstName": "Andreas",
    "lastName": "Johansson",
    "email": "andreas.johansson@example.com",
    "mobilePhone": "0703112233",
    "customerCategory": "Person",
    "address": {
      "street": "Kungsgatan",
      "streetNumber": "20",
      "postalCode": "111 22",
      "postalPlace": "Stockholm",
      "countryCode": "SE"
    }
  },
  "order": {
    "number": "ORDER00001",
    "totalNetAmount": 750.00,
    "totalGrossAmount": 1000.00,
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 300.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 25.0,
        "vatAmount": 100.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 150.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 25.00,
        "vatAmount": 50.00,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    
        

Step 1.2 - AfterPay's response

In case of successful request (Status 200 "OK"), the response consists of an outcome result (Accepted, Pending, Rejected).

NOTE! If the response is not successful, here are common error codes.

{
  "Outcome": "Accepted",
  "Customer": {
    "CustomerNumber": "507885681",
    "FirstName": "Jan",
    "LastName": "Hansen",
    "AddressList": [
      {
        "Street": "Kongens gate 2",
        "PostalCode": "0153",
        "PostalPlace": "Oslo",
        "CountryCode": "NO"
      }
    ]
  },
  "ReservationId": "00000000-0000-0000-0000-000000000000",
  "CheckoutId": "00000000-0000-0000-0000-000000000000"
}
                

{
  "Outcome": "Accepted",
  "Customer": {
    "CustomerNumber": "507885683",
    "FirstName": "Antti",
    "LastName": "Virtanen",
    "AddressList": [
      {
        "Street": "Kaisaniemenkatu 13A",
        "PostalCode": "00101",
        "PostalPlace": "Helsinki",
        "CountryCode": "FI"
      }
    ]
  },
  "ReservationId": "00000000-0000-0000-0000-000000000000",
  "CheckoutId": "00000000-0000-0000-0000-000000000000"
}
                

{
  "Outcome": "Accepted",
  "Customer": {
    "CustomerNumber": "507885684",
    "FirstName": "William",
    "LastName": "Jensen",
    "AddressList": [
      {
        "Street": "Østbanegade",
        "StreetNumber": "55",
        "PostalCode": "2100",
        "PostalPlace": "Kopenhagen",
        "CountryCode": "DK"
      }
    ]
  },
  "ReservationId": "00000000-0000-0000-0000-000000000000",
  "CheckoutId": "00000000-0000-0000-0000-000000000000"
}
                

{
  "Outcome": "Accepted",
  "Customer": {
    "CustomerNumber": "507885682",
    "FirstName": "Andreas",
    "LastName": "Johansson",
    "AddressList": [
      {
        "Street": "Kungsgatan",
        "StreetNumber": "20",
        "PostalCode": "111 22",
        "PostalPlace": "Stockholm",
        "CountryCode": "SE"
      }
    ]
  },
  "ReservationId": "00000000-0000-0000-0000-000000000000",
  "CheckoutId": "00000000-0000-0000-0000-000000000000"
}