Build Redirect Payment Page

chevron-rightCreate Payment Sessionhashtag

A windowed time for the end customer to complete the payment, starting when the client initiates the payment request through your app. The payment session duration is customizable, with a default duration of 15 minutes.

POST [BASE_URL]/v2/payments

{
  "clientReferenceId": "1743240980",
  "amount": {
    "value": 10000,
    "currency": "IDR"
  },
  "paymentMethod": {
    "type": "VIRTUAL_ACCOUNT"
  },
  "paymentMethodOptions": {
    "virtualAccount": {
      "channel": "PERMATA",
      "virtualAccountName": "Reforza Harsya"
    }
  },
  "mode": "REDIRECT",
  "redirectUrl": {
    "successReturnUrl": "https://merchant.com/success",
    "failureReturnUrl": "https://merchant.com/failure",
    "expirationReturnUrl": "https://merchant.com/expiration"
  },
  "autoConfirm": true,
  "statementDescriptor": "Harsya",
  "expiryAt": "2025-03-31T23:59:05Z",
  "metadata": {
    "invoiceNo": "INV001"
  }
}
chevron-rightChoose a modehashtag

To generate Redirect Payment Page choose mode “REDIRECT”

{
  "mode": "REDIRECT"
}
chevron-rightDefine Payment Method (For final payment method)hashtag

Set autoConfirm to true and fill paymentMethod and paymentMethodOptions object to finalize payment method from the previous step

{
  "paymentMethod": {
    "type": "VIRTUAL_ACCOUNT"
  },
  "paymentMethodOptions": {
    "virtualAccount": {
      "channel": "PERMATA",
      "virtualAccountName": "Reforza Harsya"
    }
  },
  "autoConfirm": true
}
chevron-rightSend us your Success, Failure, and Expired Payment Session URLhashtag

Handle Success, Failure, and Expired cases on your Payment Session

{
  "redirectUrl": {
    "successReturnUrl": "https://merchant.com/success",
    "failureReturnUrl": "https://merchant.com/failure",
    "expirationReturnUrl": "https://merchant.com/expiration"
  }
}
chevron-rightConfirm Payment Session (For incomplete payment method)hashtag

If you set autoConfirm to false on Create Payment Session API, you can finalize Payment Method by filling paymentMethod and paymentMethodOptions objects

POST [BASE_URL]/v2/payments/{id}/confirm

{
  "paymentMethod": {
    "type": "VIRTUAL_ACCOUNT"
  },
  "paymentMethodOptions": {
    "virtualAccount": {
      "channel": "PERMATA",
      "virtualAccountName": "Reforza Harsya"
    }
  }
}
chevron-rightRedirect to Payment Pagehashtag

After creating and confirming Payment Session, redirect your customer to the URL for the Payment page returned in the response.

{
  "paymentUrl": "https://payment.harsya.com/detail?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1dWlkIjoiN2Y2NWM3NTctMzU1Zi00NjQ1LWFjMTQtMDI4YjM0YWI1MWIxIiwiaXNzIjoiYmFja2VuZC1wb3J0YWwiLCJleHAiOjE3NDM0NjU1NDV9.55-QdvI0xVtivNLJzREPDGzUbqFNEj7ouFUCvrzAIbw"
}
chevron-rightSimulate Payment hashtag

Visit the Payment Page and Simulate the Paymentarrow-up-right

Last updated