One-Step Authorization

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

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 named John. He is shopping the web for two black tablets and one black music player.
John creates an order and enters his personal data. He adds two black tablets (400 euros each) and one black music player (200 euros each) 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 John's customer and order information into an AuthorizePaymentRequest. Then, sends it to Authorize endpoint for validation.

NOTE! The merchant has chosen the payment method (Invoice) for John.


Important variables in this request

payment
object
required
type
enum
required

The payment object with the payment type is always required. Since this is an One-Step Authorize, the merchant chooses the appropriate option for John. Currently, available payment type options are:

  • Invoice
  • Account
  • Installment
  • Consolidatedinvoice
customer
object
required

Since this is an One-Step Authorize, the customer object must be defined. Otherwise, AfterPay couldn't evaluate John'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 John later.
Some important fields to note:

  • order number, which is specified by the merchant
  • totalGrossAmount, which has to match the SUM of the individual items (grossUnitPrice * quantity)
For more detailed information about this request, visit the Payment's API Documentation.

{
  "payment": {
    "type": "Invoice"
  },
  "customer": {
    "salutation": "Mr",
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@mail.com",
    "customerCategory": "Person",
    "address": {
      "street": "Gütersloher Str.",
      "streetNumber": "123",
      "postalCode": "33415",
      "postalPlace": "Verl",
      "countryCode": "DE"
    },
    "conversationLanguage": "EN"
  },
  "order": {
    "number": "ORDER000001",
    "totalGrossAmount": 1000.00,
    "items": [
      {
        "productId": "1",
        "description": "Tablet Black",
        "grossUnitPrice": 400.00,
        "quantity": 2.0,
        "imageUrl": "http://testbild.de/productimg.jpg"
      },
      {
        "productId": "2",
        "description": "MusicPlayer Black",
        "grossUnitPrice": 200.00,
        "quantity": 1.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": "507885681",
    "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"
}