One-Step Authorization using Fixed Instalments

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

AfterPay offers fixed instalment plans with predefined maturities of 3, 6, 12, 24, or 36 months. The Payment API determines which of these instalment plans can be offered. The monthly amount to be paid in a fixed instalment plan is the same during the entire plan.
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 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 (Installment) 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
customerInterestRate
number
required

In installment object, instalment profile number is always required. Customer interest rate is required only for Germany.

customer
object
required

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

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": "Installment",
    "directDebit": {
      "bankCode": "COBADEFFXXX",
      "bankAccount": "DE08478400800410041101"
    },
    "installment": {
      "profileNo": 3,
      "numberOfInstallments": 3,
      "customerInterestRate": 15.0
    }
  },
  "customer": {
    "customerNumber": "507885685",
    "salutation": "Mr",
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "mobilePhone": "01234567",
    "birthDate": "1954-12-24T00:00:00Z",
    "customerCategory": "Person",
    "address": {
      "street": "Gütersloher Str.",
      "streetNumber": "123",
      "postalCode": "33415",
      "postalPlace": "Verl",
      "countryCode": "DE"
    },
    "riskData": {
      "existingCustomer": true,
      "verifiedCustomerIdentification": true,
      "marketingOptIn": true,
      "customerSince": "2017-01-01T00:00:00Z",
      "customerClassification": "Gold",
      "acquisitionChannel": "SearchEngine",
      "hasCustomerCard": true,
      "customerCardSince": "2017-01-01T00:00:00Z",
      "customerCardClassification": "1",
      "profileTrackingId": "78987657",
      "ipAddress": "100.100.100.100",
      "numberOfTransactions": 7,
      "customerIndividualScore": "1"
    },
    "conversationLanguage": "DE"
  },
  "order": {
    "number": "ORDER000003",
    "totalNetAmount": 810.00,
    "totalGrossAmount": 1000.00,
    "risk": {
      "channelType": "Internet",
      "deliveryType": "Normal"
    },
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 324.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 19.0,
        "vatAmount": 76.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "1",
        "description": "MusicPlayer Black",
        "netUnitPrice": 162.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 19.00,
        "vatAmount": 38.00,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    

{
  "payment": {
    "type": "Installment",
    "installment": {
      "profileNo": 3,
      "numberOfInstallments": 3,
      "customerInterestRate": 15.0
    }
  },
  "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": "ORDER000001",
    "totalNetAmount": 750.00,
    "totalGrossAmount": 1000.00,
    "risk": {
      "channelType": "Internet",
      "deliveryType": "Normal"
    },
    "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": "Installment",
    "installment": {
      "profileNo": 3,
      "numberOfInstallments": 3,
      "customerInterestRate": 15.0
    }
  },
  "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,
    "risk": {
      "channelType": "Internet",
      "deliveryType": "Normal"
    },
    "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": "Installment",
    "installment": {
      "profileNo": 3,
      "numberOfInstallments": 3
    }
  },
  "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": "ORDER000001",
    "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.0,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 152.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 24.0,
        "vatAmount": 48.0,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}
    

{
  "payment": {
    "type": "Installment",
    "installment": {
      "profileNo": 3,
      "numberOfInstallments": 3,
      "customerInterestRate": 15.0
    }
  },
  "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"
    },
    "conversationLanguage": "DE"
  },
  "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.0,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 150.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 25.0,
        "vatAmount": 50.0,
        "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": "507885685",
    "FirstName": "John",
    "LastName": "Doe",
    "AddressList": [
      {
        "Street": "Gütersloher Str.",
        "StreetNumber": "123",
        "PostalCode": "33415",
        "PostalPlace": "Verl",
        "CountryCode": "DE"
      }
    ]
  },
  "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"
}
                

{
  "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"
}