Skip to main content

Payment Creation API

This section describes the Payment Creation API which allows users to click on a PAY button in merchant system and get redirected to Paylican Payment Gateway to proceed with payment. This flow does not necessitate merchant's clients to access Paylican Invoice System.

Methods and Endpoints

Get Access Token

  • HTTP Method: POST
  • URL: {{Keycloak URL}}
  • Header: 'Content-Type: application/x-www-form-urlencoded'
  • Request Body:
'username=*****' 
'password=*********'
'grant_type=password'
'client_id=invoice-system-client'

Create Payment

  • HTTP Method: POST
  • URL and Endpoint: {{Payment URL}}/api/v1/payment
  • Request Body *please see sample codes below

Request body

{
"amount": 5100.00,
"type": "XYZ",
"customerCode": "ABC123",
"merchantReference": "REF-1234",
"redirectionUrl": "https://merchant-url.com/",
"itemName": "Item name",
"beneficiaryCode": "20",
"additionalFields": [
{
"code": "documentNo",
"value": "TST1201901260"
},
{
"code": "documentDate",
"value": "2018-01-03Z"
},
{
"code": "documentReference",
"value": "LIC201900001430"
}
]
}

Response body

{
"invoiceId": "XYZ2024-ade08",
"merchantReference": "REF-1234"
}

Payment object

Parameter NameData TypeDescription
amountbigDecimalAmount to be paid
typeStringPayment Type
customerCodeStringThe customer's code that is billed and has to do the payment.
merchantReferenceStringMerchant internal reference of the document associated to the Payment.
itemNameStringItem for what the payment is done.
beneficiaryCodeStringBeneficiary code
redirectionUrlStringRedirection URL after success payment process. Must not exceed 900 characters.
additionalFieldsArrayMeta information which could be send during callback webhook process

Redirect to Payment page

  • HTTP Method redirection: GET
  • URL and Endpoint: {{Keykloak URL}}/auth/realms/PGW/protocol/openid-connect/auth?client_id=invoice-system-client&redirect_uri={{Payment URL}}/api/v1/pay/{type}/{merchantReference}/{invoiceID}

Arguments

Parameter NameData TypeDescription
typeStringPayment Type
merchantReferenceStringMerchant internal reference of the document associated to the Payment.
invoiceIdStringResponse from 1st request

Webhook Notification

Webhooks are the notifications that are sent when the payment is executed in the system.

Main field objects

Parameter NameData TypeDescription
idLongWebhook ID automatically generated by system at execution of webhook.
typeStringInvoice paid, invoice created, invoice viewed
data.idStringInvoice ID
data.statusStringInvoice status
data.totalAmountbigDecimalTotal amount to paid for the invoice.
data.documentNoStringMerchant reference
data.paymentNoStringTransaction reference
data.paymentDateZonedDateTimeDate of the payment execution
data.paymentModeStringCASH, DIRECT_PAYMENT, MOBILE_MONEY
data.collectorStringBank that processed the transaction
data.bankCodeStringBank that processed the transaction
createdAtZonedDateTimeWebhook sending time
pendingWebhooksIntegerThe difference between Maximum retry attempts and the number of calls already executed.

Additional Field objects

Parameter NameData TypeMandatory/ optionalDescription
codeStringoptionalAdditional Field code
valueStringoptionalAdditional Field value

Webhook Notification Body example

Payment initiated

{
"createdAt":"2024-03-28T14:32:47.238686329Z",
"data": {
"additionalFields": [],
"bankCode": "GNAFRI",
"collector": "GNAFRI",
"documentNo": "REF-178T876",
"id": "ABC2024-123",
"paymentDate": "2024-03-28T14:34:30.155101Z",
"paymentMode": "BANK_TRANSFER",
"paymentNo": "gup87876f",
"status": "UNPAID",
"totalAmount": 100
},
"id": 41768,
"pendingWebhooks":2,
"type": "invoice.payment_initiated"
}

Payment Error

{
"createdAt":"2024-03-28T14:32:47.238686329Z",
"data": {
"additionalFields": [],
"documentNo": "REF-178T876",
"id": "ABC2024-123",
"paymentNo": "gup87876f",
"status": "UNPAID",
"totalAmount": 100
},
"id": 41768,
"pendingWebhooks":2,
"type": "invoice.payment_error"
}

Payment Executed

{
"createdAt":"2024-03-28T14:32:47.238686329Z",
"data": {
"additionalFields": [],
"bankCode": "GNAFRI",
"collector": "GNAFRI",
"documentNo": "REF-178T876",
"id": "ABC2024-123",
"paymentDate": "2024-03-28T14:34:30.155101Z",
"paymentMode": "BANK_TRANSFER",
"paymentNo": "gup87876f",
"status": "PAID",
"totalAmount": 100
},
"id": 41768,
"pendingWebhooks":2,
"type": "invoice.payment_initiated"
}

Payment rejected

{
"createdAt":"2024-03-28T14:32:47.238686329Z",
"data": {
"additionalFields": [],
"documentNo": "REF-178T876",
"id": "ABC2024-123",
"paymentNo": "gup87876f",
"status": "UNPAID",
"totalAmount": 100
},
"id": 41768,
"pendingWebhooks":2,
"type": "invoice.payment_rejected"
}

Responses Status Codes (Code HTTP)

The response body is optional and it will be logged in Database if sent.

CodeDescription
200OK
204No content / Object deleted
400Bad Request / Returns JSON with the error message
401Unauthorized / Couldn't authenticate your request
404Not found / No such object
500Internal Server Error
503Service Unavailable / The connection is being throttled or the service is down for maintenance

Response Cases

Case 1: If the received response is null, then we keep the corresponding webhook invocation as FAILED to be retried after a certain period (depending on the webhook retry configuration of each environment) and we set the error in Paylican Invoice to SYNCH_UNAVAILABLE.

Case 2: If the HTTP response is returned with 2xx code then we mark the corresponding webhook invocation as SUCCESSFULL and we set its status to INVOCATION_SUCCESS. In case a content gets sent in the response body it gets saved in the Paylican Invoice database.

Case 3: If the HTTP response code IS NOT 2xx then we mark the corresponding webhook invocation as FAILED to be retried after a certain period (depending on the webhook retry configuration of each environment) and we set its status to INVOCATION_FAIL. In case a content gets sent in the response body it gets saved in the Paylican Invoice database.