Payments
This API allows user to pay contract fees using online payment systems.
- Execute online payment
- Change user prepaid account value
- Calculate prepaid bonus value
- Execute payment with credit card
- Execute manual payment
Execute online payment
GET Payments/Pay
Returns online payment URL and transaction identifier.
Parameters
Name | Type | Description |
---|---|---|
userId |
long |
Required. User identifier. |
amount |
long |
Required. Amount to be paid. After successful payment amount is automaticly distributet to satisfy earliest pending fees first. The parameter is divided by 100 eg. 1250 will be converted to 12.50 |
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 with.
curl -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN" http://yoursubdomain.perfectgym.com/Api/Payments/Pay ?userId=236 &amount=100
Example response
Status: 200 OK
{
"elements": [
{
"paymentUrl": "http://yourcompany.perfectgym.com/example_payment_url",
"paymentId": "PGAPI_a12b55c5-d526-4e4e-ae9c"
}
]
}
Change user prepaid account value
POST Payments/Prepaid
Use to add funds to user's prepaid account
Body parameters
Name | Type | Description |
---|---|---|
userId |
long |
Required. User identifier. |
totalAmount |
decimal |
Required. Amount to add or withdraw (negative value of amount). |
clubId |
decimal |
Identity of club where payment is made. |
paymentMethod |
string |
Method of payment: Cash, Card, Online, MoneyTransfer. |
prepaidSource |
string |
Max length 36. Identity/code/name of machine or device where payment is made. |
operationDescription |
string |
Max length 195. Description of the operation, the reaso of the operation. |
Response
Example request
In this example we request to increase prepaid balance id
= 236
.
curl -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "userId": 236, "totalAmount": 32.8, "clubId": 15, "paymentMethod": "Cash", "prepaidSource": "Machine-A01", "operationDescription": "Add money by Cash disposal machine" }' http://yoursubdomain.perfectgym.com/Api/Payments/Prepaid
Example response
Status: 200 OK
{
"elements": [
{
"operationType": "CashLessPrepaid",
"billNumber": "123",
"customerBalance": "200",
"operationDate": "2016-06-02T14:35:22"
}
]
}
Calculate prepaid bonus value
GET Payments/Prepaid/Bonus
Use to check prepaid bonus
Parameters
Name | Type | Description |
---|---|---|
amount |
decimal |
Required. Amount to calculate. |
source |
string |
The source from which the bonus should come: MembershipPortal, Internet, Web, Api. |
Response
Example request
In this example we request to check prepaid bonus for amount '200'.
curl -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN" http://yoursubdomain.perfectgym.com/Api/Payments/Prepaid/Bonus ?amount=200
Example response
Status: 200 OK
{
"elements": [
{
"amount": "200",
"bonusAmount": "2",
"totalAmount": "202"
}
]
}
Execute payment with credit card
POST Payments/PayWithCreditCard
Request executes payment with user credit card. Credit card details must be assigned using CreditCard request.
Body parameters
Name | Type | Description |
---|---|---|
userId |
long |
Required. User identifier. |
feeIds |
array |
Required. An array of long values, each representing fee identifier to be paid. |
totalAmount |
decimal |
Required. Total amount to be paid (must be equal to sum of all fees). |
Response
Payment status if operation is successful, or collection of errors with credit card payment error codes otherwise.
Example request
In this example we request payment of pending contract fees for user identified with id
= 236
.
curl -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "userId": 236, "feeIds": [3889, 3890, 3891], "totalAmount": 32.8 }' http://yoursubdomain.perfectgym.com/Api/Payments/PayWithCreditCard
Example response
Status: 200 OK
{
"elements": [
{
"status": "Success",
"errorMessage": ""
}
]
}
Example error response
Total amount is not equal to sum of all fees to be paid.
Status: 400 Bad Request
{
"errors": [
{
"code": "InvalidTotalAmount",
"property": "",
"message": ""
}
]
}
Execute manual payment
POST Payments/ManualContractPayment
Request executes manual payment for user.
Header parameters
Name | Type | Description |
---|---|---|
userId |
long |
Required. User identifier. |
Body parameters
Name | Type | Description |
---|---|---|
paidAmount |
decimal |
Required. Total amount paid. |
description |
string |
Transaction description. |
contractTransactionType |
string |
Required. Transaction type. Possible values:
|
Example request
In this example we request manual payment of pending contract for user identified with id
= 236
.
curl -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "paidAmount": 100, "description": "Transaction description", "contractTransactionType": "Manual" }' http://yoursubdomain.perfectgym.com/Api/Payments/ManualContractPayment?userId=236
Example response
Status: 200 OK
{
"elements": [
{
"status": "Success",
"errorMessage": "",
"transactionId": 32228336
}
]
}