# 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.

{% hint style="info" %}
**Auth Token** can be retrieved in your portal dashboard under **API** page.
{% endhint %}

**Request Header**

{% code overflow="wrap" %}

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

{% endcode %}

## Step 1: Getting Payment Service List

{% hint style="info" %}
Note that for **B2C** payment please use **`payment_model_reference_id`** = 1\
while **B2B** is **`payment_model_reference_id`** = 2
{% endhint %}

{% hint style="warning" %}
B2B payment service list are only available for payment type **`WEB_PAYMENT.`** Jump to **Getting B2B Payment Service** List [**here**](/api-docs/cloud-payment/payment-service.md#getting-payment-service-list-fpx-b2b)
{% endhint %}

HTTP Method: <mark style="color:yellow;">POST</mark>

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

#### Request Body

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

#### Attributes

<table><thead><tr><th width="281.3333333333333">Property</th><th width="103">Type</th><th>Description</th></tr></thead><tbody><tr><td>payment_type<mark style="color:red;">*</mark></td><td>String</td><td>Payment service type <br><br><code>WEB_PAYMENT</code> = Web Payment (FPX)<br><code>GLOBAL_CARD_PAYMENT</code> = Card<br><code>DIGITAL_PAYMENT</code> = E-Wallet<br><code>BUY_NOW_PAY_LATER</code> = Buy Now Pay Later<br><code>SWITCH_PAYPAL</code> = PayPal<br><code>GLOBAL_CARD_PAYMENT_STRIPE</code> = Stripe</td></tr><tr><td>payment_model_reference_id<mark style="color:red;">*</mark></td><td>String</td><td>The web payment (FPX) channel <br><code>1</code> = B2C<br><code>2</code> = B2B<br><br>If using other payment type than <code>WEB_PAYMENT</code> , please use <br><code>1</code> = Default</td></tr><tr><td>payment_status<mark style="color:red;">*</mark></td><td>String</td><td>Payment service channel status<br><br><code>active</code> or <code>inactive</code></td></tr></tbody></table>

#### Response

```json
{
  "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&#x20;

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

{% hint style="info" %}
Payment Service? Go to [Payment Service](/api-docs/cloud-payment/payment-service.md) to learn more about them and how to get their values.
{% endhint %}

HTTP Method: <mark style="color:yellow;">POST</mark>

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

**Request Query**

<table><thead><tr><th width="145">Query</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>invoice_no</td><td>String</td><td>Your bill number</td></tr></tbody></table>

**Request Body**

```json
{
    "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**

<table><thead><tr><th width="258">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>collection_uuid<mark style="color:red;">*</mark></td><td>String</td><td>Your <a data-mention href="/pages/uBFnFoiRAhttK0FpKVke">/pages/uBFnFoiRAhttK0FpKVke</a> UUID</td></tr><tr><td>amount<mark style="color:red;">*</mark></td><td>Decimal (10,2)</td><td>Total amount to be paid in MYR</td></tr><tr><td>callback_url<mark style="color:red;">*</mark></td><td>String</td><td>Your callback URL</td></tr><tr><td>redirect_url</td><td>String</td><td>Your redirect URL</td></tr><tr><td>full_name<mark style="color:red;">*</mark></td><td>String</td><td>Name of the payer</td></tr><tr><td>email<mark style="color:red;">*</mark></td><td>String</td><td>Email of the payer</td></tr><tr><td>phone_number<mark style="color:red;">*</mark></td><td>String</td><td>Mobile number of the payer</td></tr><tr><td>payment_service_id<mark style="color:red;">*</mark></td><td>Number</td><td>The <a data-mention href="/pages/CYqn0lckkQ0xoe26WmsT">/pages/CYqn0lckkQ0xoe26WmsT</a> ID</td></tr><tr><td>invoice_ref<mark style="color:red;">*</mark></td><td>String</td><td>Merchant Invoice Reference</td></tr></tbody></table>

**Response**

```json
{
  "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&#x20;

```postman_json
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.

{% hint style="info" %}
**Hash Key** can be retrieved in your portal dashboard under **API** page.
{% endhint %}

Sample callback response before JWT decode

{% code overflow="wrap" fullWidth="false" %}

```json
{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jE4OjAzIFBNIiwib3JpZ2luYWxfdHJhbnNhY3Rpb25fcmVzcG9uc2VfdGltZSI6IjIwMjMtMTEtMjggMTU6MTg6MDMiLCJhbGciOiJIUzI1NiJ9.sbYhLQgR6Y4MRlAyMaVPHNWOc3Bp9NvFyKOFF-npyIU",
   "response_code":2100
}
```

{% endcode %}

Sample callback response after JWT decode

```json
{
  "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_buyer_name": "MOHD IZMAN BIN MD TEH",
  "fpx_transaction_id": "2505061440020644",
  "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"
}
```

{% hint style="info" %}
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.
{% endhint %}

## 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: <mark style="color:yellow;">POST</mark>

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

#### Request Query

```json
?invoice_no=BP-AD5112621A-LNP
```

#### Attributes

<table><thead><tr><th width="281.3333333333333">Property</th><th width="103">Type</th><th>Description</th></tr></thead><tbody><tr><td>invoice_no</td><td>string</td><td>The transaction <strong>invoice number</strong> for which you want to retrieve the status can be either a system-generated invoice number or an invoice_ref added by the merchant.</td></tr></tbody></table>

#### Response

```json
{
  "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": ""
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.leanx.io/api-docs/quick-start/accepting-using-own-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
