Create an ERIP payment request
API request requirements
All requests to the bePaid API to create a payment request must:
- use HTTP Basic authentication with Shop ID and secret key;
- have the
Content-Type: application/jsonandAccept: application/jsonheaders.
A request for an ERIP payment must be a valid JSON object. If the system accepts the request, it returns a response with the pending or permanent status.
In case of an error, you will get the error status and an error description.
How ERIP payment flow works
After you get a response with the pending or permanent status, which means that the payment request is successfully created, bePaid is waiting for a payment notification from the ERIP (Raschet system).
Once the payment is made and bePaid gets a payment notification from ERIP (Raschet system), the bePaid system changes the status of the payment request to successful or failed, and it sends a webhook notification to your system. You can see the payment with the updated status in the bePaid back office.
If a payment was initiated, but not finished by any reason, the payment request gets the start status for 30 minutes and becomes invalid for another payment attempt.
In 30 minutes it gets the pending status and becomes valid again for a payment.
Statuses of ERIP payment requests
| Status | Description |
|---|---|
pending |
The payment request is successfully created. Waiting for a payment. |
auto_created |
The system created a payment request for an advance payment or a permanent payment request. Waiting for a payment. |
expired |
The payment request was not settled and became expired, or there was created another payment request with the same bill, order or agreement number. |
permanent |
The payment request is permanent. There can be several payments. |
successful |
The payment is successful. |
failed |
The payment failed. |
deleted |
The merchant deleted the payment request. |
Create a payment request
Request parameter
To create an ERIP payment request, send a POST request to https://api.bepaid.by/beyag/payments with the following parameters:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Request example
{
"request": {
"amount": 1000,
"currency": "BYN",
"description": "Payment for Order#123",
"email": "ivanpetrov@example.com",
"ip": "127.0.0.1",
"order_id": 123456789012,
"tracking_id": "AB8923",
"notification_url": "http://merchant.example.com",
"customer": {
"first_name": "Ivan",
"middle_name": "Ivanovich",
"last_name": "Petrov",
"country": "BY",
"city": "Minsk",
"zip": "220000",
"address": "Nezavisimosti street, apt. 1",
"phone": "+375172000000"
},
"payment_method": {
"type": "erip",
"account_number": "123",
"service_no": "99999999",
"service_info": [
"Payment for Order#123"
],
"receipt": [
"Thank you for payment for order#123"
]
},
"additional_data":{
"receipt_text": ["First line", "Second line"],
"notifications": [
"sms"
]
}
}
}
Request example for a payment request with a counter value
{
"request": {
"amount": 1000,
"currency": "BYN",
"description": "Payment for water supply. Counter #123",
"email": "ivanpetrov@example.com",
"ip": "127.0.0.1",
"order_id": 123456789012,
"tracking_id": "AB8923",
"notification_url": "http://merchant.example.com",
"customer": {
"first_name": "Ivan",
"middle_name": "Ivanovich",
"last_name": "Petrov",
"country": "BY",
"city": "Minsk",
"zip": "220000",
"address": "Nezavisimosti street, apt. 1",
"phone": "+375172000000"
},
"payment_method": {
"type": "erip",
"account_number": "123",
"service_no": "99999999",
"service_info": [
"Payment for water supply. Counter #123"
],
"receipt": [
"Thank you for payment"
],
"erip_devices": [
{
"name":"Cold water",
"item_unit":"m3",
"rank":"4",
"value":"1234",
"rate":"0.4392"
}
]
},
"additional_data":{
"receipt_text": ["First line", "Second line"],
"notifications": [
"sms"
]
}
}
}
Response parameters
If the system accepts the request, it returns a JSON -serialized response with the status. A similar response will be sent in a webhook notification on notification_url after a payment is finished.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Response example
{
"transaction":{
"status":"pending",
"message":"The payment request is created.",
"type":"payment",
"id":"8759cf84-e56d-44b7-a8ae-62640f6402c4",
"uid":"8759cf84-e56d-44b7-a8ae-62640f6402c4",
"order_id":"100000003495",
"amount":22000,
"currency":"BYN",
"description":"Payment for Order#123",
"tracking_id":"AB8923",
"created_at":"2015-12-07T14:21:24.420Z",
"expired_at":"2016-12-07T14:21:240Z",
"paid_at":"2016-12-07T14:40:120Z",
"manually_corrected_at": null,
"test":true,
"payment_method_type":"erip",
"billing_address":{
"first_name":"Ivan",
"middle_name": "Ivanovich",
"last_name":"Petrov",
"country":"BY",
"city":"Minsk",
"address":"Nezavisimosti street, apt. 1",
"zip":"220000",
"phone":"+375172000000"
},
"customer":{
"email":"ivanpetrov@example.com",
"ip":"127.0.0.7"
},
"payment":{
"ref_id":null,
"message":null,
"status":"pending",
"gateway_id":1
},
"erip":{
"request_id":"00000001",
"service_no":99999999,
"account_number":"123",
"transaction_id":"0000001",
"service_info":["Payment for Order#123"],
"instruction": ["'Raschet' ERIP-> Online shops/services-> B -> bePaid.by"],
"receipt":["Thank you for payment for order#123"]
}
}
}
Error response example
If an error occurred, the system returns the following response:
{
"message": "Unknown 'erip' payment method",
"errors": {
"system": [
"System error."
]
}
}
|
Get information about a payment
Using a payment UID
To get payment details by using a payment :uid, send a GET request with the authorization data to https://api.bepaid.by/beyag/payments/:uid.
Using a payment order ID
To get payment details by using a payment :order_id, send an HTTP GET request with the authorization data to https://api.bepaid.by/beyag/payments/?order_id=:order_id.
Delete a payment request by using a payment UID
If by any reason you should cancel a payment request, you can delete this request if it has the pending or permanent status.
To mark a payment request deleted, send a DELETE request with the authorization data to https://api.bepaid.by/beyag/payments/:uid.
Info
To keep the system data integrity, payment requests are never deleted from the system database. The payment request just gets the deleted status and becomes invalid for further payments.