# Payment Link

## 1. Introduction
You can manually create a payment link through the ABA PayWay Merchant Portal or the ABA Merchant App. However, we also offer flexibility by allowing you to generate payment links via API, enabling seamless integration with your existing system.

<h3>Why is this beneficial for you?</h3>

Imagine you own an online streaming shop, where customers purchase items during a live stream. Your system automatically responds to customers and requests payment by asking them to transfer funds to your bank account. This manual process can lead to several issues:

1. **Incorrect Account Number**: Buyers might enter the wrong bank account number.
2. **Incorrect Payment Amount**: Buyers may mistakenly transfer the wrong amount.
3. **Manual Verification**: As a merchant, you must carefully verify transactions before shipping products.
4. **Time-Consuming & Inefficient**: The back-and-forth communication delays order processing.

<h3> How does the Payment Link API solve these pain points?</h3>

- You can generate a payment link with the exact amount and automatically share it with the buyer.
- Once the buyer completes the payment, PayWay will notify your system, allowing you to automate the rest of the process effortlessly.


## 2. Integration Steps
:::tip[]
Before you start, make sure you have the following:
- PayWay Sandbox Account – **[Register here](https://sandbox.payway.com.kh/register-sandbox/)** to test transactions.
- Sandbox Merchant ID & API Key—You’ll receive these via email after registering for the sandbox.
:::

<Steps>
  <Step title="Create a payment link">
   To create payment link via API, please refer to this API specification [Create payment link](https://developer.payway.com.kh/create-payment-link-14530837e0.md). Once the payment link is successfully created, it will respond back as a JSON object, and there is a propery `payment_link` represent the full link of the url which you can share with your customer.
      
      **Sample response** 
  ```json
  {
      "data": {
        "id": "UD/8Hl***Ht1xQdhlw==",
        "title": "Test curl 001",
        "image": {
          "image": "",
          "filename": "",
          "size": 0
        },
        "amount": "0.03",
        "currency": "USD",
        "status": "OPEN",
        "description": "Payment link created from curl",
        "payment_limit": 5,
        "total_amount_org": 0,
        "total_refund": 0,
        "total_amount": 0,
        "total_trxn": 0,
        "created_at": "2023-04-13 03:43:30",
        "updated_at": "2023-04-13 03:43:30",
        "expired_date": 1681357409,
        "return_url": "https://domain.com",
        "merchant_ref_no": "ref00001",
        "outlet_id": "xknY***QfbOCJA==",
        "outlet_name": "Book Store",
        "payout": [],
        "payment_link": "https://dpayment-euat.payway.com.kh/JT4630l"
      },
      "status": {
        "code": "00",
        "message": "Success!"
      },
      "tran_id": 1681357410
}
  ```

  </Step>
  <Step title="Handle the payment notification">
   Once a successful payment is made on the payment link, PayWay will send a payment notification through your `return_url`. Your `return_url` shall accept `POST` method and `Content-Type` as `application/json`.
      
      **Sample pushback notification response**
      ```json
      {
          "tran_id": "123456789",
          "status": "00",
          "merchant_ref_no": "ref0001"
      }
      ```
      ------
      **tran_id**  `string` 
      Payment transaction ID generated by the payment gateway.
      
      ---
      **status** `string`
      Status of the request.
      
      ---
      **merchant_ref_no** `string`
      Your payment link reference number.
      
      ---
      
     
To get the details of the payment, use [Check transaction](https://developer.payway.com.kh/check-transaction-14530826e0.md) with the `tran_id` value from the response above.

  </Step>
</Steps>

