Accepting Using Own Page

By following these steps, you can seamlessly integrate to your application using your own bank selections page while maintaining control and visibility over transaction statuses.

Authentication

LeanX uses Auth Token to authenticate in each request's header.

Auth Token can be retrieved in your portal dashboard under API page.

Request Header

{
    "auth-token": "LP-0D7C06DE-MM|7394e58e-edee-4c42-9ca5-bcbc449f1b9f|2141df4a3cb633d5ce8683bb0c55067e5caebfbe07390dde277dc455bcc95c91723a81b5e565c7c02d68fb84e396722563016bf99e576a4b8cdbe4423fbf226b"
}

Step 1: Getting Payment Service List

Note that for B2C payment please use payment_model_reference_id = 1 while B2B is payment_model_reference_id = 2

B2B payment service list are only available for payment type WEB_PAYMENT. Jump to Getting B2B Payment Service List here

HTTP Method: POST

https://api.leanx.dev/api/v1/merchant/list-payment-services

Request Body

{
  "payment_type": "WEB_PAYMENT",
  "payment_status": "active",
  "payment_model_reference_id": 1
}

Attributes

Property
Type
Description

payment_type*

String

Payment service type WEB_PAYMENT = Web Payment (FPX) GLOBAL_CARD_PAYMENT = Card DIGITAL_PAYMENT = E-Wallet BUY_NOW_PAY_LATER = Buy Now Pay Later SWITCH_PAYPAL = PayPal GLOBAL_CARD_PAYMENT_STRIPE = Stripe

payment_model_reference_id*

String

The web payment (FPX) channel 1 = B2C 2 = B2B If using other payment type than WEB_PAYMENT , please use 1 = Default

payment_status*

String

Payment service channel status active or inactive

Response

{
  "response_code": 2000,
  "description": "SUCCESS",
  "app_version": "/api/v1",
  "talk_to_server_before": "2023-11-28T19:22:13.243431",
  "data": {
    "list": {
      "draw": 25,
      "record_total": 25,
      "record_filtered": 25,
      "data": [
        {
          "WEB_PAYMENT": [
            {
              "payment_service_id": 16,
              "payment_model_reference_id": 1,
              "payment_model_reference": "B2C",
              "unique_reference": "AFFIN_BANK_WEBPAY",
              "payment_service": "WEB_PAYMENT",
              "name": "Affin Bank",
              "record_status_id": 1,
              "record_status": "ACTIVE"
            },
            ...........
            {
              "payment_service_id": 85,
              "payment_model_reference_id": 1,
              "payment_model_reference": "B2C",
              "unique_reference": "UOB_TESTID_WEBPAY",
              "payment_service": "WEB_PAYMENT",
              "name": "United Overseas Bank - B2C Test",
              "record_status_id": 1,
              "record_status": "ACTIVE"
            }
          ]
        }
      ],
      "next_page_start": null,
      "next_page_length": null,
      "previous_page_start": null,
      "previous_page_length": null
    }
  },
  "breakdown_errors": null,
  "token": ""
}

Step 2 : Create Silent Bill

This will create a bill and return a link straight to the payment service that you chose through payment_service_id.

Payment Service? Go to Payment Service to learn more about them and how to get their values.

HTTP Method: POST

https://api.leanx.dev/api/v1/merchant/create-bill-silent

Request Query

Query
Type
Description

invoice_no

String

Your bill number

Request Body

{
    "collection_uuid": "CL-C0D7F54A90-LNP",
    "amount": 10.00,
    "redirect_url": "https://www.yourdomain.com/return-page",
    "callback_url": "https://www.yourdomain.com/api-callback-url",
    "full_name": "John Doe",
    "email": "johndoe@email.com",
    "phone_number": "0123456789",
    "payment_service_id": 33,
    "invoice_ref" : "INV202311280001"
}

Attributes

Property
Type
Description

collection_uuid*

String

amount*

Decimal (10,2)

Total amount to be paid in MYR

callback_url*

String

Your callback URL

redirect_url

String

Your redirect URL

full_name*

String

Name of the payer

email*

String

Email of the payer

phone_number*

String

Mobile number of the payer

payment_service_id*

Number

invoice_ref*

String

Merchant Invoice Reference

Response

{
  "response_code": 2000,
  "description": "SUCCESS",
  "app_version": "/api/v1",
  "talk_to_server_before": "2023-01-31T14:28:30.842232",
  "data": {
    "bill_no": "EXAMPLE-BILL-001",
    "transaction_invoice_no": "FPX1700639540AlnAnAy0",
    "redirect_url": "https://www.yourdomain.com/return-page"
  }
}

Step 3 : Callback

Upon every successful transaction, a callback will be send to the link that you provided earlier through parameter

callback_url

However, LeanX callback mechanism will send an encoded JWT message instead of plain text to provided link, which need to be decoded with a hash key before it can be read. Below are the sample of callback response before and after encoding and decoding process.

Hash Key can be retrieved in your portal dashboard under API page.

Sample callback response before JWT decode

{
"data":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnZvaWN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VfdGltZSI6IjIwMjMtMTEtMjggMTU6MTg6MDMiLCJhbGciOiJIUzI1NiJ9.sbYhLQgR6Y4MRlAyMaVPHNWOc3Bp9NvFyKOFF-npyIU",
   "response_code":2100
}

Sample callback response after JWT decode

{
  "invoice_no": "BP1701155880uBMwB9q0",
  "client_data": {
    "merchant_invoice_no": "LXPAYeubb68W1701155842uNHhS",
    "uuid": "8ef4ce50-aebb-4d8c-b142-4fa2a089fd06",
    "order_id": "None"
  },
  "invoice_status_id": 2,
  "invoice_type_id": 1,
  "invoice_type": "NORMAL_COLLECTION",
  "invoice_status": "SUCCESS",
  "amount": "456.20",
  "payment_model_reference_id": 1,
  "rate_type_reference_id": 2,
  "payment_service_id": 89,
  "client_redirect_url": "https://www.yourdomain.com/return-page",
  "client_callback_url": "https://www.yourdomain.com/api-callback-url",
  "client_transaction_details": null,
  "prefund_collection": {
    "item": null,
    "response_code": 2100
  },
  "description": null,
  "card_token": null,
  "fpx_debit_auth_code": "00",
  "fpx_credit_auth_code": "00",
  "fpx_debit_status": "Approved",
  "transaction_response_time": "28 November 23 03:18:03 PM",
  "original_transaction_response_time": "2023-11-28 15:18:03"
}

If you are integrating via your application, the hash key will always be an identifier or a signature to ensure that the callback was intended to be send to you. If the hash key is incorrect, it might be coming from unknown sources.

Step 4 : Getting Transaction Status

The Transaction Status API provides a link to retrieve the status of previous transactions, encompassing all payment statuses. This method is recommended over the callback approach for checking transaction status.

HTTP Method: POST

https://api.leanx.dev/api/v1/merchant/manual-checking-transaction

Request Query

?invoice_no=BP-AD5112621A-LNP

Attributes

Property
Type
Description

invoice_no

string

The transaction invoice number for which you want to retrieve the status can be either a system-generated invoice number or an invoice_ref added by the merchant.

Response

{
  "response_code": 2000,
  "description": "SUCCESS",
  "app_version": "/api/v1",
  "talk_to_server_before": "2024-03-29T15:59:17.597177",
  "data": {
    "transaction_details": {
      "invoice_no": "BP-AD5112621A-LNP",
      "fpx_invoice_no": "FPX17116902144iiAlu58",
      "amount": "15.00",
      "invoice_status": "SUCCESS",
      "providerTypeReference": "FPX",
      "bank_provider": "Maybank2U",
      "category_code": "WEBPAY",
      "amount_with_fee": 15.80,
      "fee": 0.80,
      "fee_by_customer": false
    },
    "customer_details": {
      "name": "Ahmad Fuad",
      "phone_number": "0123249478",
      "email": "ahmadfuadzamri@gmail.com"
    }
  },
  "breakdown_errors": "",
  "token": ""
}

Last updated