Batch Processing Guide

Learn how to use batch transactions in order to make efficient recurring payments

The Payment API's batch processing capabilities enable you to send multiple transactions for processing at once, enabling greater efficiency and simpler processing. Our batch processing capability is flexible, enabling you to adapt and use it according to your business needs.

Example scenario: batch processing for recurring payments

In this tutorial, we walk through an example for merchants who manage their own subscription orders and want to process their shoppers' recurring payments in a batch. This is easy to achieve by saving the shopper's payment info in BlueSnap, running a query in your system to obtain a list of the subscriptions with payments due, and then compiling those subscription payments into a single batch file to send to BlueSnap for processing.

Step 1: Save payment info for new shoppers

When a new shopper first signs up for a subscription, you'll want to save their payment information in BlueSnap so that you can easily use that information to make future recurring payments.

To save the shopper's details, you can either send BlueSnap a Create Vaulted Shopper request, or simply process the transaction using a request like an Auth Capture.

In either case, BlueSnap will create a vaulted shopper with the information you sent, and send you a response with the ID number we assigned to that stored shopper.

Now all you need to do is associate that vaulted shopper ID from BlueSnap with the shopper in your own system.

Step 2: Build and sent the batch request for shoppers whose recurring payment is due

In the subscription management system on your end, pull a list of the subscription payments that are due and the relevant vaulted shopper ID for each one. For example, you might do this each day in order to process all payments that are due that day.

Now you can build a Create Batch Transaction request with the relevant charge amount per shopper. If there is more than one credit card stored for a specific shopper, you'll need to specify which card should be charged.

In the request, you also need to include:

  • a unique ID for the batch
  • a callback URL, which is where BlueSnap will send the full batch result once all transactions are processed

Here is an example request with two vaulted shoppers:

{
    "cardTransaction": [
        {
            "amount": 15,
            "vaultedShopperId": 12345678,
            "recurringTransaction": "RECURRING",
            "merchantTransactionId": 566,
            "softDescriptor": "Description1",
            "currency": "USD",
            "cardTransactionType": "AUTH_CAPTURE"
        },
        {
            "amount": 20,
            "vaultedShopperId": 87654321,
            "recurringTransaction": "RECURRING",
            "merchantTransactionId": 567,
            "softDescriptor": "Description2",
            "currency": "USD",
            "cardTransactionType": "AUTH_CAPTURE"
        }
    ],
    "callbackUrl": "http://example.com/batch_callback",
    "batchId": 99999
}

Upon sending the request, you'll get an immediate response. If successful, the response HTTP status code is 201 Created. If an error occurs, details will be sent in the response. See Batch transaction errors.

3. Get the batch results back and update your system

Once the transactions in the batch have been processed, BlueSnap will send details about the status of the batch to the callback URL you sent in the Create Batch Transaction request. You can then update your internal system with the information about each completed payment.

Example Batch Result

The batch result includes the batchTransaction resource with processingInfo per transaction.

{
   "batchTransaction": {
      "batchId": "123789001ABCD",
      "callbackUrl": "http://example/callbackurl",
      "transactionCount": "2",
      "cardTransaction": [
         {
            "cardTransactionType": "AUTH_CAPTURE",
            "merchantTransactionId": "566",
            "transactionId": "38481682",
            "amount": "110",
            "currency": "USD",
            "cardHolderInfo": {
               "firstName": "test first name",
               "lastName": "test last name"
            },
            "creditCard": {
               "cardLastFourDigits": "1881",
               "expirationMonth": "7",
               "expirationYear": "2016"
            },
            "transactionMetaData": "",
            "processingInfo": {
               "processingStatus": "SUCCESS"
            }
         },
         {
            "cardTransactionType": "AUTH_CAPTURE",
            "merchantTransactionId": "566",
            "amount": "110",
            "currency": "USD",
            "cardHolderInfo": {
               "firstName": "test first name1",
               "lastName": "test last name1"
            },
            "creditCard": {
               "cardLastFourDigits": "9299",
               "expirationMonth": "1",
               "expirationYear": "2018"
            },
            "transactionMetaData": "",
            "processingInfo": {
               "processingStatus": "FAIL",
               "processingErrors": {
                  "processingError": {
                     "processingErrorCode": "14002",
                     "processingErrorDescription": "Transaction failed  because of payment processing failure.: 400120"
                  }
               }
            }
         }
      ],
      "processingInfo": {
         "processingStatus": "COMPLETED"
      },
   }
}