Register Charge and Refund Transactions from Your Backend
This feature allows you to register charge and refund transactions in your backend instead of in
the app. Use this option if you'd like your backend to initiate the transaction, e.g.,
because of architectural reasons. You'll receive a
sessionIdentifier
that
you can send down to your app, and then execute the transaction from the app. Use WebHooks to keep your
backend informed about the status of the transaction.Register a Charge Transaction from Your Backend
Before there's anything to pay, your app will most likely be offering some sort of checkout
functionality. Information about the purchased items will be transmitted to your backend
and your backend will then be able to determine the final amount to be charged.
You will use this information to register a new transaction via
an API call to the platform:
{ "transaction" : { "amount": 123.34, "currency": "EUR", "type": "CHARGE", "subject": "My subject", "customIdentifier": "My custom identifier" } }
Important Parameters
- $.transaction.amount
- The amount of money that is about to be charged.
- $.transaction.currency
- The currency used for the transaction.
- $.transaction.type
- Use CHARGE to receive money from the shopper.
- $.transaction.customIdentifier
- An identifier that you can assign to the transaction.
The response body will look something like this:
Response
{ "status": "ok", "data": { "validUntil": "2013-09-03 11:18:34", "identifier": "0f487dc3-35cd-4125-8b82-631c7d5b328c", "transaction": { "identifier": "3fe8fe7c-b620-4b45-b128-545b8c16f236", "customIdentifier": "1234", "status": "INITIALIZED", "subject": "My subject", "groupIdentifier": "59b57c79-7a04-4e68-9bc1-78dbf71adf32", "processingDetails": {…}, "receiptDetails": {…}, "type": "CHARGE", "paymentDetails": {…}, "locationDetails": {…}, "currency": "EUR", "mode": "TEST", "amount": 123.34, "created": "2013-09-03 11:03:34", "statusDetails": {…}, "reader": {…} } } }
In addition to other information about the transaction, the response body contains two
important identifiers:
- $.data.identifier
- This is thesessionIdentifierthat should be returned by you to the app. The app will then use this identifier to start processing the transaction from the mobile device.
- $.data.transaction.identifier
- ThetransactionIdentifiershould be kept by your backend as a reference to the just registered transaction. It can then be used to do different things such as querying the platform to fetch the current status of a transaction or to cancel the transaction if necessary.
Complete the Transaction in the App with the PayButton
On iOS, provide the
sessionIdentifier
to
createTransactionViewControllerWithSessionIdentifier
:[ui createTransactionViewControllerWithSessionIdentifier:@"sessionIdentifier" completed:^(UIViewController *controller, MPUTransactionResult result, MPTransaction *transaction) { if (result == MPUTransactionResultApproved) { // Payment was approved! } else { // Payment was declined/aborted! } }];
On Android, provide the
sessionIdentifier
to
createTransactionIntent
:Intent intent = ui.createTransactionIntent(sessionIdentifier);
Complete the transaction in the application if you are using the SDK
Integration Once you have a
sessionIdentifier
, you can execute
the transaction from the app. For iOS, use:[transactionProvider startPaymentWithSessionIdentifier: /* put your sessionIdentifier here! */ ...];
For Android, use:
transactionProvider.startPayment(/* put your sessionIdentifier here! */, ...);
How to handle the callbacks of these methods is described here.
Register a Refund Transaction
You only need to use this if you do card present refunds. A different API call is used to implement card not present refunds.
To refund a previously charge transaction, register a refund transaction and pass the
transactionIdentifier
of the charge transaction as the
referencedTransactionIdentifier
. Provide the exact same
amount
and currency
.{ "transaction" : { "referencedTransactionIdentifier": "3fe8fe7c-b620-4b45-b128-545b8c16f236", "amount": 123.34, "currency": "EUR", "type": "REFUND", "mode": "TEST", "subject": "My Refund" } }
Important
Parameters
- $.transaction.referencedTransactionIdentifier
- ThetransactionIdentifierof the previous charge transaction.
- $.transaction.amount
- The amount of money that is about to be refunded.
- $.transaction.currency
- The currency used for the transaction.
- $.transaction.type
- Use REFUND to send money to the shopper.
- $.transaction.mode
- Use TEST on the test platform, use LIVE on the live platform.