Deprecated - API v1 will be switched off on 01.07.2022. Please upgrade to API v2
Product purchase
Buy product
POST Products/Product/Buy
Use to buy product
Body parameters
Name | Type | Description |
---|---|---|
userId |
long |
Required. User identifier. |
productId |
long |
Required. Product identifier. |
quantity |
long |
Required. Product quantity. |
paymentMethod |
string |
Payment method - 'Prepaid' (default), 'Debit', 'Credit'. |
Response
Example request
In this example we request to buy product with productId
= 2
for user identified with id
= 236
.
curl -i -X POST -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "userId": 236, "productId": 2, "quantity": 1 }' http://yoursubdomain.perfectgym.com/Api/Products/Product/Buy
Example response
Status: 200 OK
{
"elements": [
{
"operationType": "CashLessPrepaid",
"billNumber": "123",
"customerBalance": "200",
"operationDate": "2016-06-02T14:35:22"
}
]
}
Execute online payment for product
POST Products/Product/BuyOnline
Returns online payment URL and transaction identifier.
Parameters
Name | Type | Description |
---|---|---|
productId |
long |
Required. Product identifier. |
quantity |
long |
Required. Product quantity. |
redirectUrl |
string |
URL with query paymentId parameter attached. Online payment system will redirect to a given url after transaction is completed. |
Response
Payment details including payment URL user should be redirected to, to proceed with a payment.
Example request
In this example we request payment URL, user can execute payment to buy product with productId
= 2
.
curl -i -X POST -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "productId": 2, "quantity": 1 }' http://yoursubdomain.perfectgym.com/Api/Products/Product/BuyOnline
Example response
Status: 200 OK
{
"elements": [
{
"paymentUrl": "http://yourcompany.perfectgym.com/example_payment_url",
"paymentId": "PGAPI_a12b55c5-d526-4e4e-ae9c"
}
]
}