# Integration

TIP

The API documentation can be accessed via https://developers.purwantara.id (opens new window)

# 1. Creating a Token

Create a token on the Settings > API page.

# 2. Creating a Payment Channel

Parameter Description
TOKEN The token created in step #1
PAYLOAD The data required for the request to Purwantara. For more information, see the API (opens new window) page.
CHANNEL Endpoint channel (virtual-account, qris, ewallet/ovo, ewallet/shopeepay, payment-link and counter).
  • cURL
  • Nodejs
  • Go
  • Python
  • PHP
curl -X POST https://api.purwantara.id/v1/CHANNEL
  -H "Accept: application/json"
  -H "Authorization: Bearer TOKEN"
  -d 'PAYLOAD'

# 3. Displaying Responses in Your Application

Every response from the above requests can be used directly in the application you create and used for payment methods to your customers.

# 4. Webhook / Callback

Every time a change occurs in a created transaction, Purwantara will send a notification to the URL that you can register at Settings > Team > Callback URL.

Each notification will include a signature using HMAC (opens new window). By verifying this signature, you confirm that the notification was sent by Purwantara.

# Step 1: Fetching Data from HTTP Request

You need to retrieve data from the HTTP request, specifically the headers and payload, to use in the signature verification process. The example data for headers and payload is as follows:

# HEADERS
[
    "Accept" => "*/*",
    "Signature" => "8ba2b42168c2493e2bab000c1e00563fde688b6651f924f6ad9586e73ae66261",
    "User-Agent" => "PPN-WH",
    "Content-Type" => "application/json",
    "X-PPN-Delivery" => "a656aff8-e8e8-40bb-a6a1-8321dc51f02b"
]

# PAYLOAD
$payload = [
    "uuid" => "9cb83507-a0ab-4d59-ae53-123456789012",
    "event" => [
        "meta" => [
            "customer_phone" => "08123456789"
        ],
        "type" => "payment-link",
        "channel" => "OVO"
    ],
    "title" => "Demo",
    "amount" => "10000.0000",
    "status" => "ACTIVE",
    "paid_at" => null,
    "settle_at" => null,
    "channel_id" => 8,
    "created_at" => "2023-07-26T03:04:05.000000Z",
    "expires_at" => "2023-08-31T05:00:00.000000Z",
    "return_url" => null,
    "description" => "Demo",
    "external_id" => null,
    "payment_link_url" => "http://purwantara.id/share/payment-links/9cb83507-a0ab-4d59-ae53-123456789012"
];

# Step 2: Creating and Verifying the Signature

In this step, you will use the hash_hmac() function to create a signature from the given payload and using the predefined secret key. Next, you will compare the calculated signature with the signature sent in the headers.

$secret               = 'S3CRE7'; // From Team's settings
$payloadJson          = json_encode($payload);
$calculatedSignature  = hash_hmac('sha256', $payloadJson, $secret);
$receivedSignature    = $headers['Signature'];

if ($calculatedSignature === $receivedSignature) {
    // Valid signature, the request originates from Purwantara
    // Continue with the necessary processing
} else {
    // Invalid signature, the request might be unauthorized
    // Take appropriate action, such as rejecting the request
}

# Sandbox

We have provided a sandbox mode so that you can play with the API without incurring any charges or transferring real money. In sandbox mode, your interactions do not directly affect data or send real transactions via our network. This gives you the opportunity to thoroughly test your integration before going live.

Platform URL
Main Platform https://sandbox.purwantara.id
API https://sandbox-api.purwantara.id
Payment Simulator https://simulator.purwantara.id