Afterpay (v1)

This document will guide you on how to correctly integrate Afterpay with PowerBoard.

Afterpay

This document will guide you on how to correctly integrate Afterpay via PowerBoard.

afterpay icon

👍

Before you begin

When sending requests to PowerBoard’s API, you must provide either a Public Key and/or Secret Key depending on your use case.

API keys are generated via PowerBoard’s Merchant Dashboard, in three easy steps:

  1. Login to the PowerBoard Merchant Dashboard.
  2. Click on the ‘My Company’ link and proceed to the ‘API and Security’ heading.
  3. On screen, you’ll see both Public and Secret Key required to send requests to PowerBoard’s API.

You will also need to ensure that the Afterpay service on your PowerBoard Merchant Dashboard is set to 'Version 1'


🚧

Third-Party Requirements


Integration Steps

Step 1) Create and initialise the PowerBoard Widget

  • Embed PowerBoard's Client-SDK in your page.
  • Create a button container for the PowerBoard widget.
  • Set the PowerBoard Widget environment to 'preproduction_cba'.
  • Call the .setMeta method and populate data for your AfterPay transaction.
  • Set 'finish' event listener for Payment Source Token.
<script src="https://widget.preproduction.powerboard.commbank.com.au/sdk/latest/widget.umd.js"></script>
 
<button type="button-afterpay" id="button-afterpay">Launch AfterPay via PowerBoard</button>
 
<script>
var button = new cba.AfterpayCheckoutButton("#button-afterpay", "YOUR_POWERBOARD_PUBLIC_KEY", "YOUR_POWERBOARD_GATEWAY_ID");
 
button.setEnv("preproduction_cba");
 
button.setMeta({
    amount: "100",
    currency: "AUD",
    reference: "AfterPay Test Transaction",
    email: "[email protected]",
    first_name: "John",
    last_name: "Citizen",
    address_line: "123 Test Street",
    address_city: "Sydney",
    address_state: "NSW",
    address_postcode: "2000",
    address_country: "Australia",
    phone: "0411123123",
});
 
button.on('finish', function (data) {
    console.log('on:finish event data from PowerBoard Widget', data);
});
</script>

'finish' event will return the following fields:

FieldDescription
payment_source_tokenPowerBoard payment source token used in Charge API request.
checkout_emailPayer's email address listed on AfterPay account.
checkout_holderPayer's name listed on AfterPay account.
gateway_typePowerBoard gateway service type.

{
    "payment_source_token": "POWERBOARD_PAYMENT_SOURCE_TOKEN",
    "checkout_email": "[email protected]",
    "checkout_holder": "John Citizen",
    "gateway_type": "Afterpay"
}

Step 2) Send Payment Token to PowerBoard's API

Use the 'Payment Source Token' provided by the PowerBoard Client-SDK within your Charge API request.


API Endpointhttps://api.preproduction.powerboard.commbank.com.au/v1/charges
HTTP Method
POST
Headersx-user-secret-key- POWERBOARD_SECRET_KEY - This is your PowerBoard API Secret Key.
Content-Type - application/jsonContent - Type will always be application/json.
Request Parametersamount - string - Total amount for your Afterpay transaction.
currency - string - Always set to 'AUD'.
reference - string - Reference for the transaction. This reference may assist to identify the transaction in your back-end systems. For example, a purchase order number or invoice number.
token - string - paymentsource_token string returned from the widget in the 'finish' event.
Example: "payment_source": "c2a69078-110c-4081-a927-167d9d1b2f04"
customer.first_name - _string
- Customer First Name.
customer.last_name - string - Customer Last Name.
customer.phone - string - Customer phone number.
customer.email - string - Customer email address.
customer.payment_source.address_line1 - string - Customer Address, line 1.
customer.payment_source.address_line2 - string - Customer Address, line 2.
customer.payment_source.city - string - Customer City.
customer.payment_source.state - string - Customer State.
customer.payment_source.postcode - string - Customer Postcode.
customer.payment_source.country - string - Customer Country.

Example transaction request and response

{
    "amount": "100.00",
    "currency": "AUD",
    "reference": "Invoice 123456789",
    "token": "251985e6-a368-4168-8e1a-bfb30c3e4bab",
    "customer": {
        "first_name": "John",
        "last_name": "Citizen",
        "phone": "0412123123",
        "email": "[email protected]",
        "payment_source": {
            "address_line1": "123 Test Street",
            "address_line2": "Unit 123",
            "address_city": "Sydney",
            "address_state": "NSW",
            "address_postcode": "2000",
            "address_country": "Australia"
        }
    }
}
{
    "status": 201,
    "error": null,
    "resource": {
        "type": "charge",
        "data": {
            "transfer": {
                "items": []
            },
            "schedule": {
                "stopped": false
            },
            "statistics": {
                "total_refunded_amount": 0,
                "full_refund": false,
                "need_sync": true
            },
            "customer": {
                "payment_source": {
                    "type": "checkout",
                    "gateway_id": "63cf46d142194166721498ed",
                    "gateway_name": "Afterpay",
                    "gateway_type": "Afterpay",
                    "ref_token": "001.oi49tpl6sr0t6ektnd1st1v6v1a7ctbuartmm49ve9ec7c25",
                    "address_line1": "123 Test Street",
                    "address_city": "Sydney",
                    "address_postcode": "2000",
                    "address_state": "NSW",
                    "address_country": "Australia"
                },
                "first_name": "Test",
                "last_name": "Transaction",
                "email": "[email protected]"
            },
            "type": "financial",
            "status": "complete",
            "capture": true,
            "authorization": false,
            "archived": false,
            "one_off": true,
            "_source_ip_address": "0.0.0.0",
            "_id": "63eae3dba412be2c507ce6c4",
            "amount": 108,
            "currency": "AUD",
            "items": [],
            "transactions": [
                {
                    "type": "sale",
                    "status": "complete",
                    "_source_ip_address": "0.0.0.0",
                    "gateway_specific_code": null,
                    "gateway_specific_description": null,
                    "error_message": null,
                    "error_code": null,
                    "status_code": null,
                    "status_code_description": null,
                    "include_authorization": false,
                    "_id": "63eae3dba412be2c507ce6c5",
                    "currency": "AUD",
                    "amount": 100,
                    "amount_fee": null,
                    "amount_surcharge": null,
                    "amount_original": null,
                    "created_at": "2023-02-14T01:28:59.172Z",
                    "external_id": "25315836"
                }
            ],
            "company_id": "63cf32a154a870183bf2398a",
            "amount_surcharge": null,
            "amount_original": null,
            "updated_at": "2023-02-14T01:28:59.822Z",
            "created_at": "2023-02-14T01:28:59.173Z",
            "__v": 0,
            "external_id": "25315836"
        }
    }
}

PowerBoard will respond accordingly with a '201 Created', this response should be stored against your database or relevant payments ecosystem.