Direct Payment
Overview.
The provided API documentation details the payInvoice endpoint within the Paylink API framework. This specific endpoint is designed for merchants, enabling them to create invoices and accept online payments through the Paylink gateway. The integration process facilitates the collection of card information directly from customers. This information is then utilized for processing payments on your webpage. Notably, this method provides immediate results regarding the payment status, eliminating the need for webpage redirections.
Important Note
To request activation of the direct payment feature, adherence to Payment Card Industry Data Security Standards (PCI DSS) is mandatory, and obtaining PCI DSS certification is essential. Compliance with these standards is a legal requirement. Non-compliance not only endangers customer data but also exposes you to the possibility of substantial penalties.
Once you have ensured compliance and obtained the necessary certification, please reach out to your account manager or sales representative to enable the Direct Payment feature.
Available Payment Methods for Direct Integration
It's essential to be aware that not all Payment Methods support the Direct Payment feature. For detailed information, please consult with your account manager.
Environment
Paylink has two environments which are testing and production environments. The base server link of both environments are:
Testing:
The testing server base is https://restpilot.paylink.sa.
Production:
The production server base is https://restapi.paylink.sa.
Authentication
This endpoint requires authentication using a bearer token provided by RestPilot Paylink. The token should be included in the Authorization header of the request.
Endpoint
POST /api/payInvoice
Request Headers
Header | Required | Description |
---|---|---|
Authorization | Yes | Bearer token provided by Authentication Endpoint |
Accept | Yes | It must be set to application/JSON. |
Content-Type | Yes | It must be set to application/JSON. |
{
"Authorization": "Bearer [id_token]",
"Accept": "application/json",
"Content-Type": "application/json"
}
Request Body Parameters
Creating an invoice requires information on the new invoice, such as the amount, callback URL, and client email. The following table describes the body parameters.
Parameter | Type | Required | Description |
---|---|---|---|
amount | float | Yes | The total amount of the invoice. NOTE: Buyer will pay this amount regardless of the total amounts of the products' prices. |
callBackUrl | string | No | The URL will be called when the payment is complete or canceled. |
clientEmail | string | No | The email address of the client. |
clientMobile | string | Yes | The mobile number of the client. |
currency | string | No | The currency code of the invoice. The default value is SAR. (e.g., USD, EUR, GBP). |
clientName | string | Yes | The name of the client. |
note | string | No | A note for the invoice. |
orderNumber | string | Yes | A unique identifier for the invoice. |
products | array | Yes | An array of product objects will be included in the invoice. See product object details below. |
smsMessage | string | No | This option will enable the invoice to be sent to the client's mobile specified in clientMobile. The message of this SMS can have placeholder for dynamic content. The placeholders are: - [CLIENT_NAME]: Name of the client. - [TRANSACTION_NO]: Transaction number from Paylink of the invoice. - [ORDER_NUMBER]: The order number of the invoice. - [QR_URL]: The URL that display QR code of the invoice. - [MOB_URL]: The URL of the simple invoice format for mobile devices. - [SHORT_URL]: The short URL of the invoice. - [AMOUNT]: The amount of the invoice. - [WEB_URL]: The full URL of the invoice.NOTE: The service requires additional aggrement with Paylink sales. |
supportedCardBrands | Array | No | List of supported card brands. This list is optional. values are: [mada, visaMastercard, amex, tabby, tamara, stcpay, urpay] |
displayPending | Boolean | No | This option will make this invoice displayed in my.paylink.sa |
card | Object | Yes | The card object within the provided JSON structure represents the credit or debit card information required for processing a payment. It contains three fields: Expiry: This is an object itself, housing the card's expiration date. It's split into two parts: month and year. In the given example, the month is "04", indicating April, and the year is "28", presumably representing 2028. Number: This is the card number, a sequence of digits unique to each card. In this case, the number provided is "4111111111111111", which is a commonly used placeholder in payment processing examples. Security code: Also known as the CVV (Card Verification Value), this is a security feature for card-not-present transactions. Here, it is given as "446". |
Product Object Details
Parameter | Type | Required | Description |
---|---|---|---|
title | string | Yes | The title of the product. |
price | float | Yes | The price of the product. |
qty | int | Yes | The quantity of the product. |
description | string | No | A description of the product. |
isDigital | bool | No | Set to true if the product is digital. |
imageSrc | string | No | A URL to an image of the product. |
specificVat | float | No | The VAT rate for the product. This will override the default VAT rate for the invoice if set. |
productCost | float | No | The cost of the product. This will be used to calculate the profit margin for the merchant. |
An example of the request is as follows:
{
"amount": 5,
"callBackUrl": "https://www.example.com",
"clientEmail": "[email protected]",
"clientMobile": "0509200900",
"clientName": "Zaid Matooq",
"note": "This invoice is for VIP client.",
"orderNumber": "MERCHANT-ANY-UNIQUE-ORDER-NUMBER-123123123",
"card":{
"expiry": {
"month": "04",
"year": "28"
},
"number": "4111111111111111",
"securityCode":"446"
},
"products": [
{
"description": "Brown Hand bag leather for ladies",
"imageSrc": "http://merchantwebsite.com/img/img1.jpg",
"isDigital": true,
"price": 150,
"qty": 1,
"title": "Hand bag"
}
]
}
Success Response
If the add invoice request success. The response details are as follows:
Parameter | Type | Description |
---|---|---|
gatewayOrderRequest | Object | The invoice details were sent to the gateway. See details below. |
amount | Float | The total amount of the invoice. |
transactionNo | String | The gateway assigns the transaction number. |
orderStatus | String | The status of the invoice. |
paymentErrors | String | Any payment errors that occurred. |
url | String | The URL to the 3DS page. |
success | Boolean | This field indicates whether this endpoint operation is successful or not. NOTE: This is not the payment or order status. It is the endpoint for getting invoice details. |
digitalOrder | Boolean | This field indicates whether the order contains digital products or not. |
foreignCurrencyRate | Float | This is about the foreign currency rate used in the transaction, if applicable. In addition, it includes the exchange rate related to the SAR currency. |
Failure Response:
If any failure occurred, the response details are as follows
Parameter | Type | Description |
---|---|---|
detail | string | A detailed error message explaining the reason for the failure. |
title | string | A short title for the error that summarizes the reason for the failure. |
type | string | A URL that identifies the type of error. |
status | string | The HTTP status code for the response. |
Important Note
Invoice minimum amount
The minimum invoice amount in the Paylink system is SAR 5.00.
Important use of GetInvoice in server side
Merchant's application must perform this endpoint on the server-side. Then send the resulting response to the client-side. If this endpoint is used in the client-side, then its result must be verified and confirmed using GetInvoice endpoint from the server-side to check the orderStatus equal to piad and the amount paid.
Try the endpoint
For more detail about the endpoint and to try it out, please click here.
Updated 7 months ago