First Request
Once you’ve set up the merchant and the integration, you can make your first pay request.
curl 'https://stage.reactivepay.com/api/v1/payments' \-X POST \-H 'Content-Type: application/json' \-H 'Authorization: Bearer 2b2f542d9694bf784ab0' \-d '{ "amount": 123456, "currency": "EUR", "card": { "cvv": "123", "pan": "4242424242424242", "holder": "Test holder", "expires": "02/2077" }, "customer": { "email": "email@mail.com" }, "product": "first product"}'If the setup was done correctly, you should receive a POST request to /pay.
{ "method_name": "pay"}In this form, however, the request isn’t useful.
To make a request to the provider’s API, you need at minimum the parameters passed by the merchant: card, amount, currency. You also need the key to authorize the request to the provider, and possibly other merchant settings.
To fix this, add the required parameters to the integration settings:
curl 'https://stage.reactivepay.com/api/v1/gateway_settings' \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic YWRtaW46YWRtaW4=' \ -d ' ... "gateway_key": "my_gateway", "methods": { "pay": { "enable_status_checker": true, "final_waiting_seconds": 10, "params_fields": { "params": [], "payment": [], "settings": [] "params": ["pan", "expires", "holder", "cvv"], "payment": ["gateway_currency", "gateway_amount"], "settings": ["api_key"] } }, "status": { "params_fields": { "params": [], "payment": [], "settings": [] "settings": ["api_key"] } } }, ...'Now, by repeating the merchant request, we get useful data we can use to make a request to the provider’s API.
{ "settings": { "api_key": "0266e225-4225-4ed1-94f7-1b612d15e948" }, "params": { "pan": "4242424242424242", "expires": "02/2077", "holder": "Test holder", "cvv": "123" }, "payment": { "gateway_currency": "EUR", "gateway_amount": 123456 }, "method_name": "pay"}After making the request to the gateway, the integration must return one of the following responses:
{"status": "approved","amount": 123456,"currency": "EUR","logs": [],"result": true}{"status": "declined","details": "Friendly error message","amount": 123456,"currency": "EUR","logs": [],"result": true}{"status": "pending","amount": 123456,"currency": "EUR","logs": [],"result": true}{"error": "Internal error message","logs": [],"result": false}