Order management

To fit into organizing nature of your business the Order Management is an important part of payments. Order Management enables you to manage all transactions that happen for an order. Easily capture previously authorized funds, void an unsettled transaction, or do a full or partial refund of a settled transaction.

Full Capture

As the merchant has just handed over Astrid’s shipment to the courier, he marks it shipped in his warehouse system, which means the authorization can now be captured. Because the order contents were already provided in the AUTHORIZE call, and the merchant is shipping all of the items together, this will be a Full Capture. There is no need to put anything in the body of the CAPTURES call.

The webshop sends a POST call to the CAPTURES endpoint of the AfterPay eCommerce API. Embedded in the URL is the Order.Number from the previous AUTHORIZE call

The eCom API responds with a message containing the following information:

  • Captured Amount – how much money was moved from the Reservation to the merchant’s settlement account in AfterPay. This money now belongs to the merchant, and the merchant doesn’t have to worry about Astrid paying her bill.
  • Authorized Amount – how much money was originally reserved when the AUTHORIZE call was sent and accepted.
    • Relevant for partial captures.
  • Remaining Authorized Amount – how much money can still be captured on this order.
    • Relevant for partial captures.
  • Capture Number – a unique ID of this Capture transaction in AfterPay’s system.
    • Relevant if you need to refund an order.

The merchant can also do a partial capture. This will be described in a different example; in the meantime, you can see the detailed API documentation for more.

POST https://sandbox.afterpay.io/api/v3/orders/{orderNumber}/captures

RESPONSE from eCom API


{
  "CapturedAmount": 2085.00,
  "AuthorizedAmount": 2085.00,
  "RemainingAuthorizedAmount": 0.00,
  "CaptureNumber": "800001138"
}
                

Partial Capture

Based on the example of the API Walkthrough, let’s take a pretty common scenario:

Astrid made her purchase, but the merchant checks his warehouse and sees that the socks she ordered are not in stock. He knows he is getting a new shipment of socks next week; he is willing to accept the cost of shipping the socks separately, rather than risk losing Astrid as a customer.

The merchant sends Astrid an email explaining this, and then does a Partial Capture on the rest of her order – everything but the socks.

The response contains the following information:

  • Captured Amount – the total amount captured by this API call.
  • Authorized Amount – the original amount of the full order, as it was provided in the AUTHORIZE call.
  • Remaining Authorized Amount – how much money is left for possible captures after this partial capture.
  • Capture Number – the unique ID of this capture in the AfterPay system. Needed for Refunds etc.

If you did not include the order item details in the AUTHORIZE call, you must include them in the CAPTURE call – essentially doing a Partial Capture for the full contents of the order.

You can do multiple Partial Captures for the same order, as long as there is money left over in the Remaining Authorized Amount.

In this example, the merchant cannot charge Astrid extra for shipping the socks as a second package – he can only charge her a maximum of 2085 SEK, as per the original order.


As long as you included the order item details in the AUTHORIZE call, you can make a Partial Capture followed by a Full Capture – capturing the rest of the outstanding order.


POST https://sandbox.afterpay.io/api/v3/orders/{orderNumber}/captures

Partial capture REQUEST


{
  "orderDetails": {
    "totalGrossAmount": 2035.00,
    "items": [
      {
        "productId": "0001-BLK-M",
        "description": "Leather jacket, Black, size M",
        "grossUnitPrice": 1000.00,
        "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.00,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "imageUrl": "https://cdn.afterpay.io/dev-portal/images/black_leather_jacket.jpg",
        "lineNumber": 2
      },
      {
        "productId": "0004-BRN-M",
        "description": "Woolen hat, brown, Size M",
        "grossUnitPrice": 30.00,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "imageUrl": "https://cdn.afterpay.io/dev-portal/images/brown_wool_hat.jpg",
        "lineNumber": 4
      },
      {
        "productId": "SHIP",
        "description": "Shipping",
        "type": "ShippingFee",
        "grossUnitPrice": 5.00,
        "quantity": 1.0,
        "vatPercent": 20.0,
        "lineNumber": 5
      }
    ]
  }
}
                

RESPONSE from eCom API


{
  "capturedAmount": 2035.00,
  "authorizedAmount": 2085.00,
  "remainingAuthorizedAmount": 50.00,
  "captureNumber": "800001157"
}