Accept a Cash Payment
Allow your users without a bank account to purchase your products or services
This payment option is ideal for those customers who want to purchase the products or services available on your iOS app, but do not have a card or a bank account. To do so, you need to capture your customer’s basic details, to generate a reference or “voucher”, with which your user will be able to make the payment at a physical point of the collection entity of their choice.
1. Set up your App
The APP is responsible for collecting the basic user’s payment data, generating a token for that information through Kushki’s servers and sending that information to your back end to start the payment process.
Install Kushki’s SDK
We will use CocoaPods for its installation. If you do not have it already installed, you can get the latest version here.
Embed the library in your project, by adding the following line to your Podfile
:
pod 'Kushki', '~> 2.4.2'
Then run the following command:
pod install
For updating to the latest version, run this:
pod update Kushki
Set it up
let publicMerchantId = "public-merchant-id"let kushki =Kushki(publicMerchantId: publicMerchantId,currency: "PEN",environment: KushkiEnvironment.testing)
Request the Token and submit it to your Back-end
Once the user enters their payment information in the form, use the following example to obtain the token and submit it:
private func requestKushkiToken(name : String, lastName: String, identification: String, documentType: String, totalAmount: String, email: String) {let publicMerchantId = "publicMerchantId"let kushki = Kushki(publicMerchantId: publicMerchantId,currency: "PEN",environment: KushkiEnvironment.testing)kushki.requestCashToken(name: name, lastName: lastName, identification: identification, documentType: documentType, totalAmount: Double(totalAmount) ?? 0.0, email: email) { transaction inlet message = transaction.isSuccessful() ?transaction.token : transaction.code + ": " + transaction.message// transaction.code + ": " + transaction.messageDispatchQueue.main.async(execute: {let alert = UIAlertController(title: "Kushki Token request",message: message,preferredStyle: UIAlertController.Style.alert)alert.addAction(UIAlertAction(title: "Ok", style: .default))self.present(alert, animated: true)})self.ResponseView.text = "Token response: \n\n" + message}}
2. Set up your Back-end
The back-end is responsible for receiving the token obtained from your front end and starting the payment process with Kushki.
When the user submits the form, your front end sends a token to an endpoint that you specified previously. Using this token, you must make a call to our charges endpoint to start the charge.
- Javascript
- Python
- PHP
var data = JSON.stringify({"token": "e518ce73fdc2b0a72903ee232ff3437c","expirationDate": "2021-11-20 21:00:00","amount": {"subtotalIva": 0,"subtotalIva0": 49.99,"iva": 0,"extraTaxes": {"propina": 10}}});var xhr = new XMLHttpRequest();xhr.withCredentials = true;xhr.addEventListener("readystatechange", function () {if (this.readyState === this.DONE) {console.log(this.responseText);}});xhr.open("POST", "https://api-uat.kushkipagos.com/cash/v1/charges/init");xhr.setRequestHeader("content-type", "application/json");xhr.send(data);
import requestsurl = "https://api-uat.kushkipagos.com/cash/v1/charges/init"payload = "{\"token\":\"e518ce73fdc2b0a72903ee232ff3437c\",\"expirationDate\":\"2021-11-20 21:00:00\",\"amount\":{\"subtotalIva\":0,\"subtotalIva0\":49.99,\"iva\":0,\"extraTaxes\":{\"propina\":10}}}"headers = {'content-type': 'application/json'}response = requests.request("POST", url, data=payload, headers=headers)print(response.text)
<?php$client = new http\Client;$request = new http\Client\Request;$body = new http\Message\Body;$body->append('{"token":"e518ce73fdc2b0a72903ee232ff3437c","expirationDate":"2020-11-20 21:00:00","amount":{"subtotalIva":0,"subtotalIva0":49.99,"iva":0,"extraTaxes":{"propina":10}}}');$request->setRequestUrl('https://api-uat.kushkipagos.com/cash/v1/charges/init');$request->setRequestMethod('POST');$request->setBody($body);$request->setHeaders(array('content-type' => 'application/json'));$client->enqueue($request)->send();$response = $client->getResponse();echo $response->getBody();
According to the consumption response of the method to initiate the transaction, redirect the user to the URL of the PDF of the voucher so that your customer can download and print it and thus make the payment at the authorized location of the collection entity of their choice.
3. Test your Integration
There are test identification numbers that you can use to simulate status to ensure that your integration is ready. Use them in the token request (front end):
- Approved Transaction: Any identification number
- Initialized transaction:
9999999999
- Declined Transaction:
1000000000
4. Prepare your Certification
Read the following guidelines for technical certification approval (required to obtain productive account credentials):
- The calculation of taxes and the total amount must be the correct amount.
- Messages displayed on the screen are in line with Kushki’s responses.
- All Kushki responses must be saved and recorded (required in case you need support).
- Make sure to send all the data required as specified in the [API Reference
- Kushki’s logo must be visible for the customer. You can find our logo in several formats here.
If you design your own voucher, also consider the following:
- The pin must be visible.
- The agreement number must be visible. (only if the Init response contains it).
- The voucher expiry date must be visible.
- Cash points where the PIN can be used to make the payment must be visible.
- The total amount is visible.
- The barcode is displayed (in case it is included in the response of the charge endpoint ).
Accept Webhooks
Manage correctly post-payment events.
Check the status of your transactions
In addition to the receipt and the payment pin, you will also receive a TicketNumber which is the identifier of your transaction in Kushki and also corresponds to the parameter that you can use to check the status of the transactions through our API.