With Pay Money Standard and Express, you can easily and safely receive online payments from your customer.
This document is a guide on how to integrate Merchant Payment with Rest API.
The API is a restful web service, which accept form data as input. All methods are implemented as POST.
Before anything to do the user (who is paying to the merchant) must be logged in to get the authorization token.
URL: https://top.crocopay.tech/api/login
Method Type: POST
Sample Request: BODY PARAMETER (form-data)
{"email":"exemple@exemple.com","password":"123456"}
| Parameter | Description | Status | Type | Sample |
|---|---|---|---|---|
| Must be email | Required | String | david.luca@gmail.com | |
| password | User Password | Required | String | 123456 |
Login Successful
{"response":{"user_id":4,"first_name":"David","last_name":"Luca","email":"david.luca@gmail.com","formattedPhone":null,"picture":"","defaultCountry":"US","TOKEN":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Ijg0OGU2NjhhZDdjMWRmYzhjODA1NGE0NjY5ZTM0OGYyND","STATUS":200,"USER-STATUS":"ACTIVE"}}
Login Error
{"response":{"status":401,"message":"Invalid email & credentials"}}
N.B: You have to use this genereted TOKEN on all other steps as Authorization-token in the header section.
URL: https://top.crocopay.tech/api/v2/access-token
Method: POST
Description: Go to merchant account, https://top.crocopay.tech/merchants Click gear icon of
approved express merchant.
From the modal copy client_id, client_secret. This method is used to
generate an access token.
N.B: If the merchant is approved by the admin, only then the gear icon will be available for that merchant.
BODY PARAMETER (form-data)
{" client_id":" yMKqAvC2dILUyhwdIbryh4rsl784kF"," client_secret":" ZubitDCg2QyxuoSu0l6pJkNB5lOrcl1Ivy0qZlhlu8QhWHDYOelkVSNC8B0ybunOb3i832W3FC2SUuXw04Rj8kRHduMx7pdD4a48"}
| Parameter | Description | Status | Type | Sample |
|---|---|---|---|---|
| client_id | Merchant client_id | Required | String | yMKqAvC2dILUyhwdIbryh4rsl784kF |
| client_secret | Merchant client_secret | Required | String | ZubitDCg2QyxuoSu0l6pJkNB5lOrcl1Ivy0qZlhlu8QhWHDYOe... |
Merchant exists
{"access_token": "nJyp8O01Hv2bqkKthOjnw0mcte", "expires_in": 86400, "token_type": "Bearer"}
Merchant does not exist
{"status": "error", "message": "Failed to process the request."}
N.B: You have to use this genereted access_token on next step as Authorization
URL: https://top.crocopay.tech/api/v2/initiate-payment
Method: POST
Description: We use this endpoint to store the payment information. Get the access token which is generated by verifying merchant in previous step. Use “Authorization” as headers. https://top.crocopay.tech/api/login
N.B: You will need to set the Authorization: Bearer followed by the token value. Add successUrl and cancelUrl as you need.
BODY PARAMETER (form-data)
{"amount":"10","currency":"USD","successUrl":"https://top.crocopay.tech/dashboard","cancelUrl":"https://top.crocopay.tech"}
HEADER PARAMETER
{"Authorization":"Bearer nJyp8O01Hv2bqkKthOjnw0mcte"}
| Parameter | Description | Status | Type | Sample |
|---|---|---|---|---|
| amount | The amount User have to pay. | Required | Double | 10 |
| currency | The payment occur on which currency, it should be ISO code. | Required | String | USD |
| successUrl | Application dashboard url | Required | String | https://top.crocopay.tech/dashboard |
| cancelUrl | Application root url | Required | String | https://top.crocopay.tech |
| callbackUrl | Callback url | Required | String | https://top.crocopay.tech/api/payment?user_id={user_id} |
| Authorization | Must be given in header, collect it from Access Token | Required | String | Bearer nJyp8O01Hv2bqkKthOjnw0mcte |
Success
{"status": "success","message": "Initiated payment successfully.","redirect_url": "http://localhost/pay_v4.1/restapi/payment?grant_id=78784424&token=DuMJThhEimrrdiCKrW2A"}
Invalid Currency
{"status": "error","message": "Currency UAH is not supported by this merchant."}
Amount Zero
{"status": "error","message": "Amount cannot be 0 or less than 0."}
URL: https://top.crocopay.tech/api/v2/payment-verify
Method: POST
Description: In this endpoint payment will success, Checks all kinds of input validation and redirected to payment page (if user not logged in then user have to login) if all validation passed. User have to decide to cancel or accept the payment. User grant_id & token as body parameter which is generated in previous step.
BODY PARAMETER (form-data)
{"transaction_id":"8479E89BD4192"}
HEADER PARAMETER
{"Authorization":"Bearer C49L8XNLz84PiE4I4HYEsOBlog"}
| Parameter | Description | Status | Type | Sample |
|---|---|---|---|---|
| Transaction Id | Get from endpoint-2 | Required | String | 8479E89BD4192 |
| Authorization | Must be given in header. | Required | String | Bearer nJyp8O01Hv2bqkKthOjnw0mcte |
Payment Success
{"user_id": 1,"currency_id": 1,"payment_method_id": 1,"merchant_id": 1,"uuid": "2997108A5FD15","transaction_type_id": 10,"user_type": "registered","subtotal": "138","percentage": "2","charge_percentage": "2","charge_fixed": "0","total": "140","status": "Success"}
Merchant & User same
{"success":{"status":801,"message":"Merchant cannot make payment to himself!"}}
Grant Id or Token Mismatch
{"success":{"status":401,"message":"Grant Id or Token does not Match!"}}
Insufficient Balance
{"success":{"status":401,"message":"User doesn't have sufficient balance!"}}