{"_id":"59a45d457ee621000fc9d3f5","category":{"_id":"59a45d447ee621000fc9d3c6","version":"59a45d437ee621000fc9d3b7","project":"57336fd5a6a9c40e00e13a0b","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-03T20:45:01.593Z","from_sync":false,"order":14,"slug":"topics","title":"Guides & Tools"},"parentDoc":null,"project":"57336fd5a6a9c40e00e13a0b","user":"560d5913af97231900938124","version":{"_id":"59a45d437ee621000fc9d3b7","project":"57336fd5a6a9c40e00e13a0b","__v":1,"createdAt":"2017-08-28T18:13:23.840Z","releaseDate":"2017-08-28T18:13:23.840Z","categories":["59a45d447ee621000fc9d3b8","59a45d447ee621000fc9d3b9","59a45d447ee621000fc9d3ba","59a45d447ee621000fc9d3bb","59a45d447ee621000fc9d3bc","59a45d447ee621000fc9d3bd","59a45d447ee621000fc9d3be","59a45d447ee621000fc9d3bf","59a45d447ee621000fc9d3c0","59a45d447ee621000fc9d3c1","59a45d447ee621000fc9d3c2","59a45d447ee621000fc9d3c3","59a45d447ee621000fc9d3c4","59a45d447ee621000fc9d3c5","59a45d447ee621000fc9d3c6","59a45d447ee621000fc9d3c7"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"3.22.1","version_clean":"8976.0.0-XML","version":"8976-XML"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-08T14:16:29.939Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":107,"body":"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.\n\n###Example scenario: batch processing for recurring payments\nIn 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. \n\n###Step 1: Save payment info for new shoppers\nWhen 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.\n\nTo save the shopper's details, you can either send BlueSnap a [Create Vaulted Shopper](doc:create-vaulted-shopper) request, or simply process the transaction using a request like an [Auth Capture](doc:auth-capture).\n\nIn 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. \n\nNow all you need to do is associate that vaulted shopper ID from BlueSnap with the shopper in your own system.\n\n###Step 2: Build and sent the batch request for shoppers whose recurring payment is due\nIn 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.\n\nNow you can build a [Create Batch Transaction](doc: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. \n\nIn the request, you also need to include:\n  * a unique ID for the batch\n  * a callback URL, which is where BlueSnap will send the full batch result once all transactions are processed\n\nHere is an example request with two vaulted shoppers:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<batch-transaction xmlns=\\\"http://ws.plimus.com\\\">\\n   <batch-id>99999</batch-id>\\n   <callback-url>http://example.com/batch_callback</callback-url>\\n   <card-transaction>\\n      <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n      <merchant-transaction-id>566</merchant-transaction-id>\\n      <recurring-transaction>RECURRING</recurring-transaction>\\n      <soft-descriptor>Description1</soft-descriptor>\\n      <amount>15.00</amount>\\n      <currency>USD</currency>\\n      <vaulted-shopper-id>12345678</vaulted-shopper-id>\\n   </card-transaction>\\n   <card-transaction>\\n      <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n      <merchant-transaction-id>567</merchant-transaction-id>\\n      <recurring-transaction>RECURRING</recurring-transaction>\\n      <soft-descriptor>Description2</soft-descriptor>\\n      <amount>20.00</amount>\\n      <currency>USD</currency>\\n      <vaulted-shopper-id>87654321</vaulted-shopper-id>\\n   </card-transaction>\\n</batch-transaction>\",\n      \"language\": \"xml\",\n      \"name\": \"Create Batch Transaction Request\"\n    }\n  ]\n}\n[/block]\nUpon 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](doc:batch-errors).\n\n###3. Get the batch results back and update your system\nOnce 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](doc:create-batch-transaction) request. You can then update your internal system with the information about each completed payment.\n\n###Example Batch Result\nThe batch result includes the [batch-transaction](doc:batch-transaction) resource with `processing-info` per transaction.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\\n<batch-transaction xmlns=\\\"http://ws.plimus.com\\\">\\n  <batch-id>123789001ABCD</batch-id>\\n  <callback-url>http://example/callbackurl</callback-url>\\n  <transaction-count>2</transaction-count>\\n  <card-transaction>\\n    <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n    <merchant-transaction-id>566</merchant-transaction-id>\\n    <transaction-id>38481682</transaction-id>\\n    <recurring-transaction>ECOMMERCE</recurring-transaction>\\n    <amount>110</amount>\\n    <currency>USD</currency>\\n    <card-holder-info>\\n      <first-name>test first name</first-name>\\n      <last-name>test last name</last-name>\\n    </card-holder-info>\\n    <credit-card>\\n      <card-last-four-digits>1881</card-last-four-digits>\\n      <expiration-month>7</expiration-month>\\n      <expiration-year>2016</expiration-year>\\n    </credit-card>\\n    <transaction-meta-data/>\\n    <processing-info>\\n      <processing-status>SUCCESS</processing-status>\\n    </processing-info>\\n  </card-transaction>\\n  <card-transaction>\\n    <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n    <merchant-transaction-id>566</merchant-transaction-id>\\n    <recurring-transaction>ECOMMERCE</recurring-transaction>\\n    <amount>110</amount>\\n    <currency>USD</currency>\\n    <card-holder-info>\\n      <first-name>test first name1</first-name>\\n      <last-name>test last name1</last-name>\\n    </card-holder-info>\\n    <credit-card>\\n      <card-last-four-digits>9299</card-last-four-digits>\\n      <expiration-month>1</expiration-month>\\n      <expiration-year>2018</expiration-year>\\n    </credit-card>\\n    <transaction-meta-data/>\\n    <processing-info>\\n      <processing-status>FAIL</processing-status>\\n      <processing-errors>\\n        <processing-error>\\n          <processing-error-code>14002</processing-error-code>\\n          <processing-error-description>Transaction failed  because of payment processing failure.: 400120</processing-error-description>\\n        </processing-error>\\n      </processing-errors>\\n    </processing-info>\\n  </card-transaction>\\n  <processing-info>\\n    <processing-status>COMPLETED</processing-status>\\n  </processing-info>\\n</batch-transaction>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]","excerpt":"Learn how to use batch transactions in order to make efficient recurring payments","slug":"batch-processing-tutorial","type":"basic","title":"Batch Processing Guide"}

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:

<batch-transaction xmlns="http://ws.plimus.com">
   <batch-id>99999</batch-id>
   <callback-url>http://example.com/batch_callback</callback-url>
   <card-transaction>
      <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
      <merchant-transaction-id>566</merchant-transaction-id>
      <recurring-transaction>RECURRING</recurring-transaction>
      <soft-descriptor>Description1</soft-descriptor>
      <amount>15.00</amount>
      <currency>USD</currency>
      <vaulted-shopper-id>12345678</vaulted-shopper-id>
   </card-transaction>
   <card-transaction>
      <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
      <merchant-transaction-id>567</merchant-transaction-id>
      <recurring-transaction>RECURRING</recurring-transaction>
      <soft-descriptor>Description2</soft-descriptor>
      <amount>20.00</amount>
      <currency>USD</currency>
      <vaulted-shopper-id>87654321</vaulted-shopper-id>
   </card-transaction>
</batch-transaction>

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 batch-transaction resource with processing-info per transaction.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<batch-transaction xmlns="http://ws.plimus.com">
  <batch-id>123789001ABCD</batch-id>
  <callback-url>http://example/callbackurl</callback-url>
  <transaction-count>2</transaction-count>
  <card-transaction>
    <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
    <merchant-transaction-id>566</merchant-transaction-id>
    <transaction-id>38481682</transaction-id>
    <recurring-transaction>ECOMMERCE</recurring-transaction>
    <amount>110</amount>
    <currency>USD</currency>
    <card-holder-info>
      <first-name>test first name</first-name>
      <last-name>test last name</last-name>
    </card-holder-info>
    <credit-card>
      <card-last-four-digits>1881</card-last-four-digits>
      <expiration-month>7</expiration-month>
      <expiration-year>2016</expiration-year>
    </credit-card>
    <transaction-meta-data/>
    <processing-info>
      <processing-status>SUCCESS</processing-status>
    </processing-info>
  </card-transaction>
  <card-transaction>
    <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
    <merchant-transaction-id>566</merchant-transaction-id>
    <recurring-transaction>ECOMMERCE</recurring-transaction>
    <amount>110</amount>
    <currency>USD</currency>
    <card-holder-info>
      <first-name>test first name1</first-name>
      <last-name>test last name1</last-name>
    </card-holder-info>
    <credit-card>
      <card-last-four-digits>9299</card-last-four-digits>
      <expiration-month>1</expiration-month>
      <expiration-year>2018</expiration-year>
    </credit-card>
    <transaction-meta-data/>
    <processing-info>
      <processing-status>FAIL</processing-status>
      <processing-errors>
        <processing-error>
          <processing-error-code>14002</processing-error-code>
          <processing-error-description>Transaction failed  because of payment processing failure.: 400120</processing-error-description>
        </processing-error>
      </processing-errors>
    </processing-info>
  </card-transaction>
  <processing-info>
    <processing-status>COMPLETED</processing-status>
  </processing-info>
</batch-transaction>