Create Payment

The following is an API endpoint to create payment.

Used to create payment.

Endpoint

/api/merchant/transaction/create

Headers

  • Name
    X-Client-Id
    Type
    uuid
    Description

    Client ID (provided by BJPAY or retrieve from our Merchant Portal).

  • Name
    X-Client-Secret
    Type
    string
    Description

    Client Secret (provided by BJPAY or retrieve from our Merchant Portal).

  • Name
    X-Request-Time
    Type
    YYYY-MM-DDTHH:mm:ssZ
    Description

    Request Time should be ISO 8601 and will be used to generate Signature.

  • Name
    Content-Type
    Type
    application/json
    Description

    Content type application/json

Body

  • Name
    paymentCode
    Type
    string
    Description

    Payment that is available API Endpoint.

  • Name
    referenceNumber
    Type
    string
    Description

    Your own reference number, can be uuid, or some id generator.

  • Name
    customerName
    Type
    string
    Description

    Your customer name.

  • Name
    customerEmail
    Type
    string
    Description

    Your customer email.

  • Name
    customerPhoneNumber
    Type
    string
    Description

    Your customer phone number.

  • Name
    finishNotifyUrl
    Type
    string
    Description

    Your Backend notify endpoint.

  • Name
    finishReturnUrl
    Type
    string
    Description

    Your Backend callback endpoint.

  • Name
    expiredAt
    Type
    string
    Description

    Expired payment in format RFC 3339.

  • Name
    totalAmount
    Type
    number
    Description

    Total amount.

  • Name
    items
    Type
    array
    Description

    List of items in the payment.

Request

Example

POST
/api/merchant/transaction/create
{
 "paymentCode": "GOPAY",
 "referenceNumber": "BJP05134e418d311b55e5cd9e13",
 "customerName": "BANGJEFF",
 "customerEmail": "[email protected]",
 "customerPhoneNumber": "62123224456",
 "finishNotifyUrl": "https://my-cool-apps.com/webhook/notify",
 "finishReturnUrl": "https://my-cool-apps.com/thankyou",
 "expiredAt": "2024-06-23T13:00:48+07:00",
 "totalAmount": 58000,
 "items": [
   {
     "name": "MLBB Diamond - 250",
     "quantity": 1,
     "amount": 58000
   }
 ]
}

Status Code

Success Responses

CodeFunctionMessageDescription
OKRCSuccess()"Success"Request completed successfully

Authentication & Authorization Errors

CodeFunctionMessageDescription
01RCUnauthorized()"Unauthorized"User lacks proper authentication or authorization

Validation Errors

CodeFunctionMessageDescription
12RCInvalidAmount()"Invalid Amount"The provided amount is invalid or malformed
13RCInvalidPaymentChannel()"Invalid Payment Channel"The specified payment channel is not supported
14RCInvalidReferenceNumber()"Invalid Transaction Reference Number"The transaction reference number is invalid
15RCInvalidTransactionItem()"Invalid Transaction Item"The transaction item data is invalid
16RCInvalidCustomerEmail()"Invalid Customer Email"The customer email format is invalid
17RCInvalidCustomerPhoneNumber()"Invalid Customer Phone Number"The customer phone number format is invalid
18RCInvalidQuantity()"Invalid Quantity"The specified quantity is invalid
19RCInvalidCurrency()"Invalid Currency"The currency code is not supported

Banking & Account Errors

CodeFunctionMessageDescription
21RCInvalidAccountNumber()"Invalid Account Number"The bank account number is invalid
22RCInvalidBankCode()"Invalid Bank Code"The bank code is not recognized
23RCInvalidRequestTime()"Invalid X-Request-Time"The request timestamp header is invalid

Request Format Errors

CodeFunctionMessageDescription
04RCMissingField(field)"Missing mandatory field (field)"A required field is missing from the request

Business Logic Errors

CodeFunctionMessageDescription
41RCTransactionNotFound()"Transaction Not Found"The requested transaction does not exist
42RCServiceUnavailable()"Service currently not available or not in active hour"Service is temporarily unavailable or outside operating hours

System Errors

CodeFunctionMessageDescription
51RCInternalError()"Internal Error"An unexpected server error occurred

Response

Example

{
"code": "OK", // Check Response Code List
"message": "Success", // Check Response Message List
"data": {
    "transactionNumber": "BJP-X9063-03A2DA25525CCF84099149",
    "referenceNumber": "BJP05134e418d311b55e5cd9e13",
    "paymentCode": "GOPAY",
    "paymentName": "GoPay",
    "customerName": "BANGJEFF",
    "customerEmail": "[email protected]",
    "customerPhoneNumber": "62123224456",
    "finishNotifyUrl": "https://my-cool-apps.com/api/notify",
    "finishReturnUrl": "https://my-cool-apps.com/api/callback",
    "expiredAt": "2024-06-23T13:00:48+07:00",
    "totalAmount": 58000,
    "fee": 1160,
    "totalReceived": 56840,
    "paymentDest": "https://simulator.sandbox.midtrans.com/gopay/partner/app/payment-pin?id=937664ad-1f53-4d89-ba99-1d0451d824de",
    "paymentDestType": "REDIRECT",
    "status": "UNPAID",
  }
}

Was this page helpful?