One-Step Authorization using Consolidated Invoice

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

Consolidate invoice is suitable for shoppers who make purchases frequently, AfterPay can combine all these purchases into a single invoice at the end of the month.
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 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 (ConsolidatedInvoice) for the customer.


Important variables in this request

payment
object
required
type
enum
required

The payment object with the payment type is always required.

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": "Consolidatedinvoice"
  },
  "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": "EN"
  },
  "order": {
    "number": "ORDER000001",
    "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.0,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 162.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 19.0,
        "vatAmount": 38.0,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}

{
  "payment": {
    "type": "Consolidatedinvoice"
  },
  "customer": {
    "customerNumber": "507885686",
    "salutation": "Mr",
    "firstName": "Max",
    "lastName": "Mustermann",
    "email": "max.mustermann@example.com",
    "mobilePhone": "0123452323",
    "birthDate": "1984-07-21T00:00:00Z",
    "customerCategory": "Person",
    "address": {
      "street": "Weyringergasse Str",
      "streetNumber": "1",
      "postalCode": "1040",
      "postalPlace": "Vienna",
      "countryCode": "AT"
    }
  },
  "order": {
    "number": "ORDER000001",
    "totalNetAmount": 800.00,
    "totalGrossAmount": 1000.00,
    "risk": {
      "channelType": "Internet",
      "deliveryType": "Normal"
    },
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 320.00,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 20.0,
        "vatAmount": 80.0,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 160.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "vatAmount": 40.0,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}

{
  "payment": {
    "type": "Consolidatedinvoice"
  },
  "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.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"
      }
    ]
  }
}

{
  "payment": {
    "type": "Consolidatedinvoice"
  },
  "customer": {
    "customerNumber": "507885687",
    "salutation": "Mr",
    "firstName": "Max",
    "lastName": "Mustermann",
    "email": "max.mustermann@example.com",
    "mobilePhone": "0123452323",
    "customerCategory": "Person",
    "address": {
      "street": "Alte Steinhauserstrasse",
      "streetNumber": "10",
      "postalCode": "CH-6330",
      "postalPlace": "Cham",
      "countryCode": "CH"
    },
    "conversationLanguage": "EN"
  },
  "order": {
    "number": "ORDER000001",
    "totalNetAmount": 923.00,
    "totalGrossAmount": 1000.00,
    "risk": {
      "deliveryType": "Normal"
    },
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "netUnitPrice": 369.2,
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "vatPercent": 7.7,
        "vatAmount": 30.8,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 184.6,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 7.7,
        "vatAmount": 15.4,
        "imageUrl": "http://testbild.de/productimg2.jpg"
      }
    ]
  }
}

{
  "payment": {
    "type": "Consolidatedinvoice"
  },
  "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": "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": "Consolidatedinvoice"
  },
  "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,
    "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": "Consolidatedinvoice"
  },
  "customer": {
    "customerNumber": "507885683",
    "identificationNumber": "080470-0247",
    "firstName": "Antti",
    "lastName": "Virtanen",
    "email": "antti.virtanen@example.com",
    "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.00,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "netUnitPrice": 152.00,
        "grossUnitPrice": 200.00,
        "quantity": 1.0,
        "vatPercent": 24.00,
        "vatAmount": 48.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": "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": "507885686",
    "FirstName": "Max",
    "LastName": "Mustermann",
    "AddressList": [
      {
        "Street": "Weyringergasse Str",
        "StreetNumber": "1",
        "PostalCode": "1040",
        "PostalPlace": "Vienna",
        "CountryCode": "AT"
      }
    ]
  },
  "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": "507885687",
    "FirstName": "Max",
    "LastName": "Mustermann",
    "AddressList": [
      {
        "Street": "Alte Steinhauserstrasse",
        "StreetNumber": "10",
        "PostalCode": "CH-6330",
        "PostalPlace": "Cham",
        "CountryCode": "CH"
      }
    ]
  },
  "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": "507885684",
    "FirstName": "Andreas",
    "LastName": "Johansson",
    "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": "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"
}