Receive one-click payments with authorization and capture

Separate the authorization and capture on subscribed cards to create a charge now and capture funds later

Web
Android
iOS

Receiving one click payments with the authorization and capture scheme allows you to securely store your customer’s card data, guaranteeing the availability of an amount on the customer’s card for a maximum of 30 days. If the payment is not captured in that time, it will be automatically cancelled and the funds will be released.

The flow you will integrate will be as follows: Auth y captura bajo demanda

1. Create the card enrollment

The first thing you must do to generate one click payments with the authorization and capture scheme, is to enroll your customer’s card. To perform the enrollment, follow the instructions given in the article Generate one click payments.

If the subscription is successful, you will receive the subscriptionId. The next thing to do from your back-end is to make an authorization request and then make a capture or unsubscription request, depending on the case.

2. Authorize the charge

With the subscriptionId of your card received in the previous step, you must make a call to our authorization endpoint to initiate the reservation of a given amount.

  • Javascript
  • Python
  • PHP
var request = require("request");
var options = {
method: 'POST',
url: 'https://api-uat.kushkipagos.com/subscriptions/v1/card/1574693127852000/authorize',
headers: {'content-type': 'application/json'},
body: {
amount: {ice: 0, iva: 0, subtotalIva: 0, subtotalIva0: 6000, currency: 'MXN'},
name: 'John',
lastName: 'Doe',
email: 'johnD@kushkipagos.com',
orderDetails: {siteDomain: 'tuebook.com',
shippingDetails: {name: 'John Doe', phone: +593988734644, address: 'Calle 13 Avenida 39 40', city: 'Guadalajara', region: 'Jalisco', country: 'México', zipCode: 170402},
billingDetails: {name: 'John Doe', phone: +593988734644, address: 'Calle 13 Avenida 39 40', city: 'Guadalajara', region: 'Jalisco', country: 'México', zipCode: 170402}
},
fullResponse: true
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import http.client
conn = http.client.HTTPSConnection("api-uat.kushkipagos.com")
payload = "{\"amount\":{\"ice\":0,\"iva\":0,\"subtotalIva\":0,\"subtotalIva0\":6000,\"currency\":\"MXN\"},\"name\":\"John\",\"lastName\":\"Doe\",\"email\":\"johnD@kushkipagos.com\",\"orderDetails\":{\"siteDomain\":\"tuebook.com\",\"shippingDetails\":{\"name\": \"John Doe\",\"phone\":\"+593988734644\",\"address\":\"Calle 13 Avenida 39 40\",\"city\":\"Guadalajara\",\"region\":\"Jalisco \",\"country\":\"México\",\"zipCode\":\"170402\"},\"billingDetails\":{\"name\":\"John Doe\",\"phone\":\"+593988734644\",\"address\":\"Calle 13 Avenida 39 40\",\"city\": "Guadalajara","region": "Jalisco","country": "México","zipCode": \"170402\"}},\"fullResponse\":true}
headers = { 'content-type': "application/json" }
conn.request("POST", "/subscriptions/v1/card/1574693127852000/authorize", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{"amount":{"ice":0,"iva":0,"subtotalIva":0,"subtotalIva0":6000,"currency":"MXN"},"name":"John","lastName":"Doe","email":"johnD@kushkipagos.com","orderDetails": {"siteDomain":"tuebook.com","shippingDetails":{"name":"John Doe","phone":"+593988734644","address":"Calle 13 Avenida 39 40","city": "Guadalajara","region":"Jalisco","country":"México","zipCode":"170402"},"billingDetails":{"name": "John Doe","phone":"+593988734644","address":"Calle 13 Avenida 39 40","city": "Guadalajara","region":"Jalisco","country":"México","zipCode": "170402"}},"fullResponse":true}');
$request->setRequestUrl('https://api-uat.kushkipagos.com/subscriptions/v1/card/1574693127852000/authorize');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

3. Kushki verifies authorization

Kushki will validate the availability of funds with the card issuer. Once the response from Kushki is obtained, save the ticketNumber as this will be the identifier to perform the capture later, as well as the cancellation.

4. Execute the charge

4.1. Make the capture (Optional)

Once you are required to collect the funds from the card, capture the amount that you define according to the authorized by calling our capture endpoint for subscriptions one click , using the subscriptionId of the card and the ticketNumber obtained in the authorization.

  • Javascript
  • Python
  • PHP
var request = require("request");
var options = {
method: 'POST',
url: 'https://api-uat.kushkipagos.com/subscriptions/v1/card/123442221212/capture',
headers: {'content-type': 'application/json'},
body: {
ticketNumber: '319228478889680318',
amount: {currency: 'MXN', subtotalIva: 0, iva: 0, subtotalIva0: 6000, ice: 0},
fullResponse: true
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import http.client
conn = http.client.HTTPSConnection("api-uat.kushkipagos.com")
payload = "{\"ticketNumber\":\"319228478889680318\",\"amount\":{\"currency\":\"MXN\",\"subtotalIva\":0,\"iva\":0,\"subtotalIva0\":6000,\"ice\":0},\"fullResponse\":true}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/subscriptions/v1/card/123442221212/capture", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{"ticketNumber":"319228478889680318","amount":{"currency":"MXN","subtotalIva":0,"iva":0,"subtotalIva0":6000,"ice":0},"fullResponse":true}');
$request->setRequestUrl('https://api-uat.kushkipagos.com/subscriptions/v1/card/123442221212/capture');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

4.2. Cancel authorization (optional)

If you need to cancel an authorization you can do it by calling our charge cancellation enpoint, using the ticketNumber obtained from the authorization.

  • Javascript
  • Python
  • PHP
var request = require("request");
var options = {
method: 'DELETE',
url: 'https://api-uat.kushkipagos.com/v1/charges/1528188291221',
headers: {'content-type': 'application/json'},
body: {
fullResponse: true,
amount: {subtotalIva: 1000, subtotalIva0: 0, ice: 0, iva: 0, currency: 'MXN'}
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import http.client
conn = http.client.HTTPSConnection("api-uat.kushkipagos.com")
payload = "{\"fullResponse\":true,\"amount\":{\"subtotalIva\":1000,\"subtotalIva0\":0,\"ice\":0,\"iva\":0,\"currency\":\"MXN\"}}"
headers = { 'content-type': "application/json" }
conn.request("DELETE", "/v1/charges/1528188291221", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{"fullResponse":true,"amount":{"subtotalIva":1000,"subtotalIva0":0,"ice":0,"iva":0,"currency":"MXN"}}');
$request->setRequestUrl('https://api-uat.kushkipagos.com/v1/charges/1528188291221');
$request->setRequestMethod('DELETE');
$request->setBody($body);
$request->setHeaders(array(
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

5. Test your integration

There are test cards you can use in the UAT environment to make sure your integration is ready. Use them with any CVV, zip code and future expiration date.

  • Approved Transaction: 5451951574925480
  • Declined transaction on token request (front-end): 4574441215190335
  • Transaction declined on authorization: 4349003000047015
  • Transaction declined on capture: 4547004841271012