Sample Code

Feel free to copy and paste.

Special Requests

If you don't find the exact sample you are looking for, make a special request. Contact helpdigitzs.com or click the blue help tab at bottom right.

Payments

Request body examples for /payments POST

Card

copy

// request body for card payment
{
  "data": {
    "type": "payments",
    "attributes": {
      "paymentType": "card",
      "merchantId": "<VALID_MERCHANT_ID>",
      "card": {
        "holder": "Jane Doe",
        "number": "4747474747474747",
        "expiry": "0218",
        "code": "999"
      },
      "transaction": {
        "amount": "100", // 100 equals $1.00
        "currency": "USD",
        "invoice": "123456" // same invoice, card, and amount within 1 minute is rejected as duplicate 
      },
      "billingAddress": { // optional
        "line1": "21 Jump Street",
        "line2": "Suite 007",
        "city": "Los Angeles",
        "state": "CA",
        "zip": "90210",
        "country": "USA"
      }
    }
  }
}

Card Split

copy

// request body for cardSplit payment
{
  "data": {
    "type": "payments",
    "attributes": {
      "paymentType": "cardSplit",
      "merchantId": "<VALID_MERCHANT_ID>",
      "card": {
        "holder": "Jane Doe",
        "number": "4747474747474747",
        "expiry": "0218",
        "code": "999"
      },
      "split": {
        "merchantId": "<VALID_MERCHANT_ID>", // merchant receiving split
        "amount": "100" // 100 equals $1.00
      },
      "transaction": {
        "amount": "500", // 500 equals $5.00
        "currency": "USD",
        "invoice": "123456"
      }
    }
  }
}

Card Refund

copy

// request body for cardRefund payment
{
  "data": {
    "type": "payments",
    "attributes": {
      "paymentType": "cardRefund",
      "merchantId": "<VALID_MERCHANT_ID>",
      "transaction": {
        "amount": "100", // 100 equals $1.00
        "currency": "USD",
        "invoice": "123456"
      },
      "originalTransaction": {
        "id": "<VALID_PAYMENT_ID>" // refund must be processed against a specific payment
      }
    }
  }
}

Token

copy

// request body for token payment
{
  "data": {
    "type": "payments",
    "attributes": {
      "paymentType": "token",
      "merchantId": "<VALID_MERCHANT_ID>",
      "token": {
        "customerId": "<VALID_CUSTOMER_ID>",
        "tokenId": "<VALID_TOKEN_ID>"
      },
      "transaction": {
        "amount": "100",
        "currency": "USD",
        "invoice": "123456"
      }
    }
  }
}

Token Split

copy

// request body for tokenSplit payment
{
  "data": {
    "type": "payments",
    "attributes": {
      "paymentType": "tokenSplit",
      "merchantId": "<VALID_MERCHANT_ID>",
      "token": {
        "customerId": "<VALID_CUSTOMER_ID>",
        "tokenId": "<VALID_TOKEN_ID>"
      },
      "split": {
        "merchantId": "<VALID_MERCHANT_ID>", // merchant receiving split
        "amount": "100"
      },
      "transaction": {
        "amount": "500",
        "currency": "USD",
        "invoice": "123456"
      }
    }
  }
}