MENU
PHP CSharp Perl Ruby

Tokenization Service API

The tokenization service allows easy integration for encrypting and storing sensitive data, then receiving a token that can be stored or used for processing transactions with that data.

Authentication and authorization for the TokenizationService will be done by a Base64 encoded companyId and APIKey in the HTTP Authorization Header. The companyId is your PDC companyId, the APIKey can be created through the PDCflow front end or by PDCflow Customer Services. These pieces of data will also have a colon between them (ex. 1234:apikey). See Sample Code

REST Request

--Credit Card

Current Version:

POST:
Use this endpoint to create a token for processing a payment
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens

POST to create a new token for provided credit card data
Use the /tokens endpoint to create a token which can be used by your company for credit card charges.

Use the /billingtokens endpoint to create a PDCflow billing token. This token will be used only when configuring your billing information through the CompanyAdministrationService. PDCflow will use this token to process your invoice. For a billing token, the authorizedForFutureUse must be set to true.

POST:
Use this endpoint to create a PDCflow billing token
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens

{
  "authorizedForFutureUse": true,
  "cardNumber":"4000100011112224",
  "expirationMonth":12,
  "expirationYear":2024
}
Attribute Description
cardNumber
Numeric16
Required
Credit card number.
expirationMonth
Required
Numeric2
The expiration month of the credit card.
Format: 2 digit month, such as 01, 08, 12, etc.
expirationYear
Required
Numeric4
The expiration year of the credit card.
Format: 4 digit year, such as 2024.
authorizedForFutureUse
Required
Boolean5
Whether a card can be used for more than one transaction. If this is set to false, the token will be created and is valid for one transaction (including subsequent CREDITs on that transaction), but an error will be returned if a new, second transaction is attempted with this token.
Must be set to true when creating a token through the /billingtokens endpoint.
Valid value(s): true, false

--Card Update

PATCH:
Use this endpoint to update the details for a card token. Append the token to the end of the URL. Only provided fields will be updated.
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens/{token}
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens/{token}

PATCH to update the card data for a provided token. The card number cannot be updated.

{
    "expirationMonth":12,
    "expirationYear":2025,
    "authorizedForFutureUse": "false"
}
Attribute Description
expirationMonth
Numeric2
The expiration month of the credit card.
Format: 2 digit month, such as 01, 08, 12, etc.
expirationYear
Numeric4
The expiration year of the credit card.
Format: 4 digit year, such as 2024.
authorizedForFutureUse
Boolean5
Whether a card can be used for more than one transaction. If this is set to false and the token has been used previously for a transaction, an error will be returned if a new transaction is attempted with this token. Otherwise, the token can be used for one transaction.
Valid value(s): true, false

--Bank Account Tokenization

POST:
Use this endpoint to create a token for processing a payment
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens

POST to create a new token for provided bank account data. The routing number and bank account type will be stored with the token for future use.
Use the /tokens endpoint to create a token which can be used by your company for bank account charges.
Use the /billingtokens endpoint to create a PDCflow billing token. This token will be used only when configuring your billing information through the CompanyAdministrationService. PDCflow will use this token to process your invoice. For a billing token, the authorizedForFutureUse must be set to true.

POST:
Use this endpoint to create a PDCflow billing token
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens

{
    "authorizedForFutureUse": true,
    "bankAccountNumber":"123456543",
    "routingNumber":"123456789",
    "accountType":"SAVINGS"
}
Attribute Description
bankAccountNumber
Numeric20
Required
Bank account number.
routingNumber
Required
The routing number for the bank.
accountType
Required
Alpha8
Valid value(s): CHECKING, SAVINGS
authorizedForFutureUse
Required
Boolean5
Whether a check can be used for more than one transaction. If this is set to false, the token will be created and is valid for one transaction (including subsequent CREDITs on that transaction), but an error will be returned if a new, second transaction is attempted with this token.
Must be set to true when creating a token through the /billingtokens endpoint.
Valid value(s): true, false

--Bank Account Update

PATCH:
Use this endpoint to update the details for a bank account token. Append the token to the end of the URL. Only provided fields will be updated.
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/{token}
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/{token}

PATCH to update the bank account data for the provided token.

{
    "bankAccountNumber":"987654321",
    "routingNumber":"111111111",
    "accountType":"CHECKING",
    "authorizedForFutureUse": "false"
}
Attribute Description
bankAccountNumber
Numeric20
Bank account number.
routingNumber
Numeric9
The routing number for the bank.
accountType
Alpha8
Valid value(s): CHECKING, SAVINGS
authorizedForFutureUse
Boolean5
Whether a check can be used for more than one transaction. If this is set to false and the token has been used previously for a transaction, an error will be returned if a new transaction is attempted with this token. Otherwise, the token can be used for one transaction.
Valid value(s): true, false

--Bulk Tokenization

Card:

POST:
Use this endpoint to create a token list for processing payments
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/bulk
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/bulk

POST to create a new token list for provided credit card data

{
  "paymentCardList": [
    {
      "cardNumber":"371122223332241",
      "expirationMonth":12,
      "expirationYear":2093,
      "authorizedForFutureUse":true,
      "uniqueId":123
    },
    {
      "cardNumber":"4000100011112224",
      "expirationMonth":12,
      "expirationYear":2093,
      "authorizedForFutureUse":true,
      "uniqueId":456
    }
  ]
}
Attribute Description
paymentCardList
ListN/A
Required
List of PaymentCard
Attribute Description
cardNumber
Numeric16
Required
Credit card number.
expirationMonth
Required
Numeric2
The expiration month of the credit card.
Format: 2 digit month, such as 01, 08, 12, etc.
expirationYear
Required
Numeric4
The expiration year of the credit card.
Format: 4 digit year, such as 2024.
authorizedForFutureUse
Required
Boolean5
Whether a card can be used for more than one transaction. If this is set to false, the token will be created and is valid for one transaction (including subsequent CREDITs on that transaction), but an error will be returned if a new, second transaction is attempted with this token.
Must be set to true when creating a token through the /billingtokens endpoint.
Valid value(s): true, false
uniqueId
AlphanumericN/A
Required
Unique Id used to match generated tokens to request items.

Bank:

POST:
Use this endpoint to create a token list for processing a payment
test url:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/bulk
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/bulk

POST to create a new token list for provided bank account data

{
  "bankAccountDataList": [
    {
      "authorizedForFutureUse":"true",
      "bankAccountNumber":"21312323123211321321",
      "routingNumber":"023456789",
      "accountType":"SAVINGS",
      "uniqueId":"124"
    },
    {
      "authorizedForFutureUse":"true",
      "bankAccountNumber":"21312323123211321321",
      "routingNumber":"023456789",
      "accountType":"SAVINGS",
      "uniqueId":"456"
    }
  ]
}
Attribute Description
bankAccountDataList
ListN/A
Required
List of BankAccountData
Attribute Description
bankAccountNumber
Numeric20
Required
Bank account number.
routingNumber
Required
The routing number for the bank.
accountType
Required
Alpha8
Valid value(s): CHECKING, SAVINGS
authorizedForFutureUse
Required
Boolean5
Whether a card can be used for more than one transaction. If this is set to false, the token will be created and is valid for one transaction (including subsequent CREDITs on that transaction), but an error will be returned if a new, second transaction is attempted with this token.
Must be set to true when creating a token through the /billingtokens endpoint.
Valid value(s): true, false
uniqueId
AlphanumericN/A
Required
Unique Id used to match generated tokens to request items.

REST Result

--Token

{
    "token": "RuxyEGxTbz0J2224",
    "mask": "4000102224"
}
Attribute Description
token
Alphanumeric16
The token for the sensitive data.
For bank accounts, the last four characters of the token are the last four of the bank account.
mask
Numeric10
The displayable mask of the sensitive data.
For bank accounts, this mask will be the last 4 of the bank account.

--TokenList

{
  "tokenList": [
    {
      "token": "44yd3pzcMVCQ2241",
      "mask": "3711222241",
      "cardData": {
        "mask": "3711222241",
        "type": "AMERICAN_EXPRESS"
      },
      "uniqueId": "123"
    },
    {
      "token": "iXvW2pXVdmN82224",
      "mask": "4000102224",
      "cardData": {
        "mask": "4000102224",
        "type": "VISA"
      },
      "uniqueId": "456"
    }
  ]
}
Attribute Description
tokenList
List of Token
Attribute Description
token
Alphanumeric16
The token for the sensitive data.
For bank accounts, the last four characters of the token are the last four of the bank account.
mask
Numeric10
The displayable mask of the sensitive data.
For bank accounts, this mask will be the last 4 of the bank account.
uniqueId
AlphanumericN/A
Required
Unique Id used to match generated tokens to request items.
cardData
Only present on paymentCard response.
Attribute Description
mask
Numeric10
The displayable mask of the sensitive data.
For bank accounts, this mask will be the last 4 of the bank account.
type
AlphanumericN/A
The type of card used.

REST Fault

RequestErrorList

Attribute Description
requestErrorList
ListN/A
A list of RequestError objects containing validation errors.
Constraint(s): Only returned when validation errors occur. See object definition below.

PaymentCardList/BankAccountDataList

{
  "paymentCardList": [
    {
      "uniqueId": "123",
      "requestErrorList": [
        {
          "code": "10004",
          "description": "Field invalid",
          "retriable": false,
          "apiFieldNameList": [
            {
              "apiFieldName": "cardNumber",
              "apiFieldValue": "[Omitted]"
            }
          ]
        }
      ]
    },
    {
      "uniqueId": "123",
      "requestErrorList": [
        {
          "code": "10013",
          "description": "UniqueIds must be unique.",
          "retriable": false
        }
      ]
    }
  ]
}
Attribute Description
paymentCardList/bankAccountDataList
ListN/A
List of PaymentCard/BankAccountData
Attribute Description
uniqueId
AlphanumericN/A
Required
Unique Id used to match generated tokens/errors to request items.
requestErrorList
ListN/A
A list of RequestError objects containing validation errors.
Constraint(s): Only returned when validation errors occur. See object definition below.

RequestError

Current Version:

{
    "requestErrorList": [
        {
            "code": "10007",
            "description": "Missing required field",
            "retriable": false,
            "apiFieldNameList": [
                {
                    "apiFieldName": "expirationMonth",
                    "apiFieldValue": 0
                }
            ]
        }
    ]
}
Attribute Description
code
Alpha3
The code for the validation error.
description
AlphanumericN/A
The description of the validation error.
retriable
Boolean5
Boolean to specify if the same request can be retried. This indicates a temporary failure, such as loss of network connectivity.
apiFieldNameList
ListN/A
List of ApiFieldName with the specified RequestError

ApiFieldName

Attribute Description
apiFieldName
Alphanumeric
The name of the Api Field.
apiFieldValue
Alphanumeric
The value of the Api Field. When the Api Field is a list, this will show the specific list value which failed.

Sample Code

This section offers some client implementation examples in different languages. Keep in mind, these are only minimalistic examples used to demonstrate the Tokenization Service REST API and are not meant for production use.

Result Status Codes

Expected Http Status codes

Status '200':
Description = 'Success.'

Status: '400':
Description = 'Malformed request. The request is either incorrectly formatted, or there are validation errors.'

Status '401':
Description = 'Invalid credentials.'

Status '405':
Description = 'POST, GET, PUT request not supported for resource.'

Status '500':
Description = 'An internal error has occurred.'

Status '503':
Description = 'The requested service (Credit Card) is not activated.'

All requests will return a status code. For example, in the case of status code 400, check for a requestErrorList in the response, containing information on validation failure.

Sample Token Creation

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;

namespace RestClient {

    public class CreditCard {
        /*
         * These variables are named camelCase style as the api expects the json parameters to be camelCase
         */
        public bool authorizedForFutureUse { get; set; }
        public string cardNumber { get; set; }    
        public int expirationMonth { get; set; }
        public int expirationYear { get; set; }
    }

    public class BankAccount {
        /*
         * These variables are named camelCase style as the api expects the json parameters to be camelCase
         */
        public bool authorizedForFutureUse { get; set; }  
        public string bankAccountNumber { get; set; }    
        public string routingNumber { get; set; }
        public string accountType { get; set; }
    }


    public class MainClass {
        private HttpClient client = new HttpClient();

        private static void Main(string[] args) {
            string url = "https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens";
            CreditCard creditCard = new CreditCard();
            creditCard.setAuthorizedForFutureUse(true);
            creditCard.SetCardNumber("4000100011112224");
            creditCard.SetExpirationMonth(12);
            creditCard.SetExpirationYear(2028);

            //string url = "https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens";
            //BankAccount bankAccount = new BankAccount();
            //bankAccount.setAuthorizedForFutureUse(true);
            //bankAccount.SetBankAccountNumber("123456789");
            //bankAccount.SetRoutingNumber("987654321");
            //bankAccount.SetAccountType("CHECKING");

            POSTData(creditCard, url);
            //POSTData(bankAccount, url);

            //Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
            client.Dispose();
        }


        private bool POSTData(Object data, string url) {
            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            // Add authentication header (base64Encoded companyId:apikey)
            var byteArray = Encoding.ASCII.GetBytes("1234:myApiKey0987");
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("apikey", Convert.ToBase64String(byteArray));

            HttpResponseMessage response = await client.PostAsJsonAsync(new Uri(url), data);
            response.EnsureSuccessStatusCode();
            /*
             * When using the .NET WebClient or HTTPWebRequest API’s, the actual response content on a bad HTTP status code response (for example, 400) is not parsed. If using these libraries, it is recommended to catch a WebException and force it to read the full stream allowing the JSON response body to be read.
             */
        }
    }

}
<?php
    $url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens';

    $apikey = 'apikey_from_front_end';
    $companyId = 1234;
    $authorization = "Authorization: apikey " . base64_encode($companyId.':'.$apikey);

    $creditCard = [
      'authorizedForFutureUse' => 'true',
      'cardNumber' => '4000100011112224',
      'expirationMonth' => 12,
      'expirationYear' => 2093
    ];

    /*
    $url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens';
    $bankAccount = [
      'authorizedForFutureUse'=>'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
    ];
    */

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $authorization));
    curl_setopt($curl, CURLOPT_POSTFIELDS, $creditCard);
    //curl_setopt($curl, CURLOPT_POSTFIELDS, $bankAccount);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);  //num seconds to try connecting
    curl_setopt($curl, CURLOPT_TIMEOUT, 30); //max number of seconds to allow execution

    $result = curl_exec($curl);

    $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    // View response
    print_r(json_decode($result, true));

    if ($statusCode == '200')
    {
      //Handle success
    }
    else
    {
        //Handle error according to status code
    }
    curl_close($curl);
#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use IO::Socket::SSL qw(debug3); # verbose for troubleshooting
use MIME::Base64 qw( encode_base64 );

eval {

   my $url = URI->new("https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens");

   my $creditCard = {
        'authorizedForFutureUse' => 'false',
        'cardNumber' => '4000100011112224',
        'expirationMonth' => 12,
        'expirationYear' => 2093
   }

    =begin comment

    my $url = URI->new("https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens");
    my $bankAccount = {
      'authorizedForFutureUse'=>'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
    }
    =end comment

    =cut

   my $data = JSON::XS->new->utf8->encode ($creditCard);
#   my $data = JSON::XS->new->utf8->encode ($bankAccount);
   my $apiKey = 'api_key_from_front_end';
   my $companyId = 1234;
   my $authHeader = HTTP::Headers->new('Authorization' => 'apikey '. encode_base64($companyId.':'.$apiKey));

   my $req = HTTP::Request->new( 'POST', $url );

   my $lwp = LWP::UserAgent->new;
   my $response = $lwp->request( $req );

   if ( $response->is_success ) {
      print "Success: " . $response->decoded_content;
   }
   else {
      die $response->status_line . ": " . $response->decoded_content;
   }
};
if ( $@ ) {
   print "Error: $@\n";
}
#!/usr/bin/ruby

require 'curl'
require 'curb'
require 'json'
require 'base64'

begin
   creditcard = {
      'authorizedForFutureUse' => 'true',
      'cardNumber' => '4000100011112224',
      'expirationMonth' => 12,
      'expirationYear' => 2093
   }

   bankaccount = {
      'authorizedForFutureUse'=>'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
   }

   apikey = 'api_key_from_front_end'
   companyId = 1234

   c = Curl::Easy.new
   c.url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens'
#   c.url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens'
   c.connect_timeout = 5
   c.timeout = 30
   c.verbose = true

   headers={}
   headers['Content-Type'] = 'application/json'
   headers['Content-Length'] = data.to_json.length
   headers['Authorization: apikey'] = Base64.encode64(companyId + ':' + apikey)
   payload = creditcard.to_json
#    payload = bankaccount.to_json

   c.headers = headers
   c.http_post(payload)

   puts JSON.parse c.body_str

   if c.response_code == 200 then
      puts "Success " + c.status
   else
      puts "Error " + c.status
   end
rescue
   puts "Caught: #$!\n"
end

General token creation will use this method. It will create a token for the provided credit card or bank account number.

Send an HTTP POST request to:
test urls:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens

Sample Bank Account Update

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;

namespace RestClient {

    public class BankAccount {
        /*
         * These variables are named camelCase style as the api expects the json parameters to be camelCase
         */
        public string bankAccountNumber { get; set; }    
        public string routingNumber { get; set; }
        public string accountType { get; set; }
    }


    public class MainClass {
        private HttpClient client = new HttpClient();

        private static void Main(string[] args) {
            string tokenToUpdate = "thisIsAToken1234";       
            string url = "https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/" + tokenToUpdate;
            BankAccount bankAccount = new BankAccount();
            bankAccount.SetRoutingNumber("987654321");

            PATCHData(bankAccount, url);

            //Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
            client.Dispose();
        }


        private bool PATCHData(Object data, string url) {
            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            // Add authentication header (base64Encoded companyId:apikey)
            var byteArray = Encoding.ASCII.GetBytes("1234:myApiKey0987");
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("apikey", Convert.ToBase64String(byteArray));

            HttpResponseMessage response = await client.PatchAsJsonAsync(new Uri(url), data);
            response.EnsureSuccessStatusCode();
            /*
             * When using the .NET WebClient or HTTPWebRequest API’s, the actual response content on a bad HTTP status code response (for example, 400) is not parsed. If using these libraries, it is recommended to catch a WebException and force it to read the full stream allowing the JSON response body to be read.
             */
        }
    }

}
<?php
    $apikey = 'apikey_from_front_end';
    $companyId = 1234;
    $authorization = "Authorization: apikey " . base64_encode($companyId.':'.$apikey);
    $tokenToUpdate = 'thisIsaToken1234';
    $url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/' . tokenToUpdate;
    $bankAccount = [
      'bankAccountNumber' => '987654321',
      'accountType' => 'CHECKING'
    ];

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $authorization));
    curl_setopt($curl, CURLOPT_POSTFIELDS, $bankAccount);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);  //num seconds to try connecting
    curl_setopt($curl, CURLOPT_TIMEOUT, 30); //max number of seconds to allow execution

    $result = curl_exec($curl);

    $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    // View response
    print_r(json_decode($result, true));

    if ($statusCode == '200')
    {
      //Handle success
    }
    else
    {
        //Handle error according to status code
    }
    curl_close($curl);
#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use IO::Socket::SSL qw(debug3); # verbose for troubleshooting
use MIME::Base64 qw( encode_base64 );

eval {
    my $tokenToUpdate = 'thisIsaToken1234';
    my $url = URI->new("https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/" . $tokenToUpdate);
    my $bankAccount = {
        'accountType' => 'CHECKING'
    }

    my $data = JSON::XS->new->utf8->encode ($bankAccount);
    my $apiKey = 'api_key_from_front_end';
    my $companyId = 1234;
    my $authHeader = HTTP::Headers->new('Authorization' => 'apikey '. encode_base64($companyId.':'.$apiKey));

    my $req = HTTP::Request->new( 'PATCH', $url );

    my $lwp = LWP::UserAgent->new;
    my $response = $lwp->request( $req );

    if ( $response->is_success ) {
        print "Success: " . $response->decoded_content;
    }
    else {
        die $response->status_line . ": " . $response->decoded_content;
    }
};
if ( $@ ) {
   print "Error: $@\n";
}
#!/usr/bin/ruby

require 'curl'
require 'curb'
require 'json'
require 'base64'

begin
    tokentoupdate = 'thisIsaToken1234'
   bankaccount = {
      'routingNumber' => '123456789'
    }

   apikey = 'api_key_from_front_end'
   companyId = 1234

   c = Curl::Easy.new
   c.url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens/' + tokentoupdate
   c.connect_timeout = 5
   c.timeout = 30
   c.verbose = true

   headers={}
   headers['Content-Type'] = 'application/json'
   headers['Content-Length'] = data.to_json.length
   headers['Authorization: apikey'] = Base64.encode64(companyId + ':' + apikey)
   payload = bankaccount.to_json

   c.headers = headers
   c.http_patch(payload)

   puts JSON.parse c.body_str

   if c.response_code == 200 then
      puts "Success " + c.status
   else
      puts "Error " + c.status
   end
rescue
   puts "Caught: #$!\n"
end

This method will be used to update the bank account information for a token. Bank Account Number, Routing Number or Bank Account Type can be updated. Information for credit cards cannot be updated.

Send an HTTP POST request to:
test urls:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens

Sample Billing Token Creation

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;

namespace RestClient {

    public class CreditCard {
        /*
         * These variables are named camelCase style as the api expects the json parameters to be camelCase
         */
        public bool authorizedForFutureUse { get; set; }
        public string cardNumber { get; set; }    
        public int expirationMonth { get; set; }
        public int expirationYear { get; set; }
    }

    public class BankAccount {
        /*
         * These variables are named camelCase style as the api expects the json parameters to be camelCase
         */
        public bool authorizedForFutureUse { get; set; }
        public string bankAccountNumber { get; set; }    
        public string routingNumber { get; set; }
        public string accountType { get; set; }
    }


    public class MainClass {
        private HttpClient client = new HttpClient();

        private static void Main(string[] args) {              
            string url = "https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens";
            CreditCard creditCard = new CreditCard();
            creditCard.setAuthorizedForFutureUse(true);
            creditCard.SetCardNumber("4000100011112224");
            creditCard.SetExpirationMonth(12);
            creditCard.SetExpirationYear(2028);

            //string url = "https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/billingtokens";
            //BankAccount bankAccount = new BankAccount();
            //bankAccount.setAuthorizedForFutureUse(true);
            //bankAccount.SetBankAccountNumber("123456789");
            //bankAccount.SetRoutingNumber("987654321");
            //bankAccount.SetAccountType("CHECKING");

            POSTData(creditCard, url);
            //POSTData(bankAccount, url);

            //Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
            client.Dispose();
        }


        private bool POSTData(object data, string url) {
            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            // Add authentication header (base64Encoded companyId:apikey)
            var byteArray = Encoding.ASCII.GetBytes("1234:myApiKey0987");
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("apikey", Convert.ToBase64String(byteArray));

            HttpResponseMessage response = await client.PostAsJsonAsync(new Uri(url), data);
            response.EnsureSuccessStatusCode();

            /*
             * When using the .NET WebClient or HTTPWebRequest API’s, the actual response content on a bad HTTP status code response (for example, 400) is not parsed. If using these libraries, it is recommended to catch a WebException and force it to read the full stream allowing the JSON response body to be read.
             */
        }
    }

}
<?php
    $url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens';

    $apikey = 'apikey_from_front_end';
    $companyId = 1234;
    $authorization = "Authorization: apikey " . base64_encode($companyId.':'.$apikey);

    $creditCard = [
      'authorizedForFutureUse' => 'true',
      'cardNumber' => '4000100011112224',
      'expirationMonth' => 12,
      'expirationYear' => 2093
    ];

    /*
    $url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/billingtokens';
    $bankAccount = [
      'authorizedForFutureUse' => 'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
    ];
    */

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $authorization));
    curl_setopt($curl, CURLOPT_POSTFIELDS, $creditCard);
    //curl_setopt($curl, CURLOPT_POSTFIELDS, $bankAccount);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);  //num seconds to try connecting
    curl_setopt($curl, CURLOPT_TIMEOUT, 30); //max number of seconds to allow execution

    $result = curl_exec($curl);

    $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    // View response
    print_r(json_decode($result, true));

    if ($statusCode == '200')
    {
      //Handle success
    }
    else
    {
        //Handle error according to status code
    }
    curl_close($curl);
#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request;
use JSON::XS;
use IO::Socket::SSL qw(debug3); # verbose for troubleshooting
use MIME::Base64 qw( encode_base64 );

eval {

   my $url = URI->new("https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens");

   my $creditCard = {
      'authorizedForFutureUse' => 'true',
      'cardNumber' => '4000100011112224',
      'expirationMonth' => 12,
      'expirationYear' => 2093
   }

    =begin comment

    my $url = URI->new("https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/billingtokens");
    my $bankAccount = {
      'authorizedForFutureUse' => 'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
    }
    =end comment

    =cut

   my $data = JSON::XS->new->utf8->encode ($creditCard);
#   my $data = JSON::XS->new->utf8->encode ($bankAccount);
   my $apiKey = 'api_key_from_front_end';
   my $companyId = 1234;
   my $authHeader = HTTP::Headers->new('Authorization' => 'apikey '. encode_base64($companyId.':'.$apiKey));

   my $req = HTTP::Request->new( 'POST', $url );

   my $lwp = LWP::UserAgent->new;
   my $response = $lwp->request( $req );

   if ( $response->is_success ) {
      print "Success: " . $response->decoded_content;
   }
   else {
      die $response->status_line . ": " . $response->decoded_content;
   }
};
if ( $@ ) {
   print "Error: $@\n";
}
#!/usr/bin/ruby

require 'curl'
require 'curb'
require 'json'
require 'base64'

begin
   creditcard = {
      'authorizedForFutureUse' => 'true',
      'cardNumber' => '4000100011112224',
      'expirationMonth' => 12,
      'expirationYear' => 2093
   }

    =begin
    bankaccount = {
      'authorizedForFutureUse' => 'true',
      'bankAccountNumber' => '987654321',
      'routingNumber' => '123456789,
      'accountType' => 'CHECKING'
    }
    =end

   apikey = 'api_key_from_front_end'
   companyId = 1234

   c = Curl::Easy.new
   c.url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/billingtokens'
#   c.url = 'https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/billingtokens'
   c.connect_timeout = 5
   c.timeout = 30
   c.verbose = true

   headers={}
   headers['Content-Type'] = 'application/json'
   headers['Content-Length'] = data.to_json.length
   headers['Authorization: apikey'] = Base64.encode64(companyId + ':' + apikey)
   payload = creditcard.to_json
#   payload = bankaccount.to_json

   c.headers = headers
   c.http_post(payload)

   puts JSON.parse c.body_str

   if c.response_code == 200 then
      puts "Success " + c.status
   else
      puts "Error " + c.status
   end
rescue
   puts "Caught: #$!\n"
end

This endpoint will be used create a token for the provided credit card, that can only be used by PDCflow for billing purposes. You will use this token when configuring your company billing information through the CompanyAdministrationService.

Send an HTTP POST request to:
test urls:
https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens https://tokenizedemo.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens
live url:
https://tokenize.pdc4u.com/TokenizationService/api/v2_0/paymentcards/tokens https://tokenize.pdc4u.com/TokenizationService/api/v2_0/bankaccounts/tokens