Create Orders API
Request Parameters
Following are the parameters to be sent in the request body:
Field | is required? | Description | Example |
---|---|---|---|
amount | mandatory | string The amount for which the Order was created | "10000" or "10000.23" for amount with decimal value |
payment_option | optional | string The type of payment option with which order was created | "full_payment" or "installment" |
currency | mandatory | string The currency associated with the Order's amount | "IDR" |
order_ref_id | optional | string The unique identifier of Order from the merchant | "INV/1/2021" |
customer | mandatory | json object The customer fields including id , email , mobile , first_name , given_name , address json object, customer_ref_id . One of id , mobile , email is mandatory field whereas others are optional . address is mandatory to use BNPL payment method. | { "email": "jane.doe@gmail.com" } |
items | optional | array Array of objects with each object including name, brand, category, sku, price, qty, total_price.mandatory to use BNPL payment method | |
metadata | optional | json object Key-Value pair that can be used to store additional information about the entity. e.g. note : Force is with this order | { "note": "Force is with this order" } |
expiry_date | optional | timestamp The time stamp at which the order will expire. Please ensure that the value is in RFC3339 format | "2022-03-29T10:00:00.000Z" |
Example
curl -X POST \
https://api.durianpay.id/v1/orders \
-H 'authorization: [Base64({Your_Server_Key}:)]' \
-H 'content-type: application/json' \
-d '{
"amount": "10000.67",
"payment_option": "full_payment",
"currency": "IDR",
"order_ref_id": "order_ref_001",
"customer": {
"customer_ref_id": "cust_001",
"given_name": "Jane Doe",
"email": "jane_doe@nomail.com",
"mobile": "85722173217",
"address": {
"receiver_name": "Jude Casper",
"receiver_phone": "8987654321",
"label": "Jude'\''s Address",
"address_line_1": "Jl. HR. Rasuna Said",
"address_line_2": "Apartment #786",
"city": "Jakarta Selatan",
"region": "Jakarta",
"country": "Indonesia",
"postal_code": "560008",
"landmark": "Kota Jakarta Selatan"
}
},
"items": [
{
"name": "LED Television",
"qty": 1,
"price": "10001.00",
"logo": "https://merchant.com/product_001/tv_image.jpg"
}
],
"metadata": {
"my-meta-key": "my-meta-value",
"SettlementGroup": "BranchName"
},
"expiry_date": "2022-03-29T10:00:00.000Z"
}'
Response Code : 200 Success
Here is an example of success response
{
"data": {
"id": "ord_0dIWbuDJQ84078",
"customer_id": "cus_ViPeX4iBYp2233",
"order_ref_id": "order_ref_001",
"amount": "10001.00",
"payment_option": "full_payment",
"currency": "IDR",
"status": "started",
"created_at": "2021-04-01T14:39:37.860426Z",
"updated_at": "2021-04-01T14:39:37.860426Z",
"expiry_date": "2022-03-29T10:00:00Z",
"metadata": {
"my-meta-key": "my-meta-value",
"SettlementGroup": "BranchName"
},
"items": [
{
"name": "LED Television",
"qty": 1,
"price": "10001.00",
"logo": "https://merchant.com/product_001/tv_image.jpg"
}
],
"access_token": "adsyoi12sdASd123ASX@qqsda231"
}
}
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=\"amount 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"
}