Create Instapay/Payment Link API


The following endpoint creates an Order:

/orders

Request parameters

Following are the parameters to be sent in the request body:

Fieldis required?Description
amountmandatorystring The amount for which the Order was created
currencymandatorystring The currency associated with the Order's amount
order_ref_idoptionalstring The unique identifier of Order from the merchant
is_payment_linkmandatorytrue Boolean flag denoting its a payment link order
customermandatoryjson object The customer fields including id, email, mobile, first_name, given_name, address_line_1, address_line_2, city, region, country, postal_code, customer_ref_id. One of id, mobile, email is mandatory field whereas others are optional.
itemsoptionalarray Array of objects with each object including name, brand, category, sku, price, qty, total_price
metadataoptionaljson object Key-Value pair that can be used to store additional information about the entity. e.g. note: Force is with this order
is_notification_enabledoptionalfalse Boolean flag to send notification email to the customer
email_subjectoptionalstring if the is_notification_enabled set true, the text in this field will be used as the notification email's subject
email_contentoptionalstring if the is_notification_enabled set true, the text in this field will be used as the notification email's body

Example

curl -X POST 
  https://api.durianpay.id/v1/orders \
  -H 'authorization: [Base64({Your_Server_Key}:)]' \
  -H 'content-type: application/json' \
  -d '{
  "amount": "20000",
  "currency": "IDR",
  "order_ref_id": "order2314", 
  "is_payment_link": true,
  "customer": {
    "email": "jude.casper@durianpay.id"
  }
}'

Response Code : 200

Here is an example of success response

{
  "data": {
    "id": "ord_A31sd3AwAgItmmXdp",
    "amount": "20000",
    "customer_id": "cus_abcd1234",
    "currency": "IDR",
    "status": "started",
    "order_ref_id": "order2314",
    "created_at": 1582628071,
    "payment_link_url": "d123ASX@qqsdaDasdd123ASX@qqsda",
    "metadata": [],
    "access_token: "adsyoi12sdASd123ASX@qqsda231" 
  } 
}

// redirect user to https://links.durianpay.id/payment/{payment_link_url})

Error Response Code : 400

Here is an example error response for invalid request

{
    "error": "required fields missing",
    "error_code": "DPAY_INVALID_REQUEST",
    "errors": [
        {
            "field": "amount=\"currency  not supported yet\"\ncurrency=\"currency invalid\"\n",
            "message": "Please provide valid order data"
        }
    ]
}

Error Response Code : 401

Here is an example error response for unauthorized access

{
    "error": "invalid Authorization header in request",
    "error_code": "DPAY_UNAUTHORIZED_ACCESS"
}