> For the complete documentation index, see [llms.txt](https://paycorp-international.gitbook.io/quick-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paycorp-international.gitbook.io/quick-web/getting-connected/initialise-the-payment.md).

# 2. Initialise the Payment

Please read the instructions carefully.

### Important Information

When initialising the payment the following is important:

* The **Client Id** is provided by Paycorp and identifies a payment channel. A single merchant may have multiple payment channels each setup or a different purpose, so the client ID is a **required field** used to identify a specific payment channel.&#x20;
* The **Client Reference** must be unique and is used to identify each payment within the merchant's system. If a payment fails or there is a network issue the status of any payment can be determined using the client reference. It is also a **required field**.
* The **return URL** specifies the endpoint hosted on the merchants server that will receive the **HTTP redirect** initiated by Paycorp after the payment has been successfully initialised. It is also a **required field**. Paycorp will submit an HTTP GET request to this endpoint.

**Payment එක ආරම්භ කිරීම**\
කරුණාකර පහත දී ඇති උපදෙස් හොදින් කියවන්න\
**වැදගත් තොරතුරු -** Payment එකක් ආර්ම්භ කිරීමීදී පහත සදහන් දෑ වැදගත් වේ.

\
1.Paycorp මගින් සපයන ලද Client id එක මගින් Payment එක යොමු වන ආකාරය හදුනා ගත හැක.එක් පරිශිලකයෙකුට Payment එක එකම අවශ්‍යතාවයකට හෝ වෙන් වෙන් අවශ්‍යතාවයන්ට යොමු කරන මාර්ග කීපයක් තිබිය හැක.එම නිසා එක් එක් Payment එක යොමුවන මාර්ගය හදුනා ගැනීමට client id එක අත්‍යවශ්‍යය.

2.පරිශීලකයකුට එක් එක් Payment එක වෙන්ව හදුනාගැනිමට Client Reference එක භාවිතා කල හැක.Payment එකක් අසමත් වූවොත්  හෝ ජාලයේ ප්‍රශ්නයක් වූවොත් Payment එකේ තත්වය Client Reference එක මගින් තීරණය කල හැක.එම නිසා එයද අත්‍යවශ්‍යය.

3.පරිශීලකයාගේ Server එකේ තිබෙන Payment එකේ response එක ලබාගන්නා ගොනුව. Return Url එකට දැමිය යුතුය.එම නිසා එයද අත්‍යවශ්‍යය.Paycorp එක HTTP GET  Request මෙම Return Url එකට එව්නු ඇත.<br>

{% hint style="info" %}
The HTTP GET request to the merchants return URL will contain the following parameters

* **Request ID:** also know as a CSRF token, this is a unique value generated by Paycorp for each new payment that has been successfully initialised. It is used to confirm the payment.
* **Client reference**: this value can be used by the merchant to identify the payment.
* REQUEST ID: CSRF TOKEN ලෙසද හැඳින්වේ, මෙය සාර්ථකව ආරම්භ කර ඇති සෑම නව ගෙවීමක් සඳහා Payocorp විසින් නිපදවන සුවිශේෂී වටිනාකමකි. ගෙවීම් තහවුරු කිරීමට එය යොදා ගනී.&#x20;
* Client Refererence: ගෙවීම් හඳුනා ගැනීමට වෙළෙන්දා විසින් මෙම අගය භාවිතා කළ හැක.
  {% endhint %}

### Examples

{% tabs %}
{% tab title="Hosted page" %}

```markup
<script>
  function buildPayment() {
    // Build the payment object
    return {
          clientId: 14002582,// Provided by Paycorp
          paymentAmount: 1010, // in CENTS
          currency: 'LKR',
          returnUrl: 'http://yourdomain/payment-response',
          clientRef: 'CREF-12345',
          comment: 'This is a demo payment'
    };
  }
</script>
```

{% endtab %}

{% tab title="IFrame" %}

```markup
<script>
  document.addEventListener("DOMContentLoaded", (event) => { 
    loadPaycorpPayment(buildPayment(), 'paycorp-payment');
  });

  function buildPayment() {
    return {
          clientId: 14000003,// supplied by paycorp
          paymentAmount: 1010,
          currency: 'LKR',
          returnUrl: 'http://yourdomain/payment-response',
          clientRef: 'CREF-12345',
          comment: 'This is a demo payment'
    };
  }
</script>

<div id="paycorp-payment" class="paycorp-payment">
</div>
```

{% endtab %}
{% endtabs %}

### Payment Init fields

| **Property**      | **Type** | **Description**                                                                             | Required |
| ----------------- | -------- | ------------------------------------------------------------------------------------------- | -------- |
| **clientId**      | number   | Client Id provided by Paycorp                                                               | yes      |
| **type**          | string   | <p>Options: PURCHASE, AUTHORISATION</p><p>Default: PURCHASE</p>                             | Yes      |
| **currency**      | string   | 3 char ISO code                                                                             | yes      |
| **tokenize**      | boolean  | Flag to tokenize card                                                                       | Optional |
| **paymentAmount** | number   | <p>The payment amount is in CENTS <br>.i.e 1000 should be entered for $10</p>               | yes      |
| **returnUrl**     | string   | The payer is redirected to this URL after submitting the payment form.                      | yes      |
| **clientRef**     | string   | Merchant specified field. *Max 50*                                                          | yes      |
| **comment**       | string   | Merchant specified field. *Max 100.*                                                        | Optional |
| **extraData**     | object   | <p>Merchant specified key value pair metadata.</p><p><code>{ key: 'value', ... }</code></p> | Optional |

<br>
