Tokenization with E-Payment Integrator


Which gateways supported by the E-Payment Integrator support tokenization?

Date Entered: 01/19/2010 Last Updated: 03/27/2020
As of the publishing of this article, the E-Payment Integrator currently supports tokenization with the following gateways:

Please note that the sample code below may not represent a complete transaction. For some gateways a token can be generated using the RecurringBilling component. In other cases, the token is generated through another method determined by the gateway. You can read more about the various Configuration settings used in the code below in the Help file.

Authorize.NET AIM XML API

Note: Authorize.Net can only process tokenized credit cards but can not generate a credit card token. Token must be issued by a certified token provider. For more information please contact the gateway directly.

Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwAuthorizeNetXML; icharge.GatewayURL = "https://apitest.authorize.net/xml/v1/request.api"; //This is your API Login ID icharge.MerchantLogin = "APILoginID"; //This is your Transaction Key icharge.MerchantPassword = "TransactionKey"; icharge.TransactionDesc = "Sale with Token Test"; icharge.TransactionAmount = "5.00"; icharge.InvoiceNumber = "12345"; icharge.TransactionId = "56789"; icharge.Config("AuthNetTokenizedCard=5424000000000015"); icharge.Config("AuthNetCryptogram=EjRWeJASNFZ4kBI0VniQEjRWeJA="); icharge.Card.ExpMonth = 12; icharge.Card.ExpYear = 2020; icharge.Sale();

Bank of America/FirstDataE4/Payeezy

//initial transaction using card data icharge.Sale(); //retrieve the token string transArmorToken = icharge.Config("FDMSTransArmorToken"); //send a transaction using token //(note that card type and expiry information are still required) icharge.Card.CardType = TCardTypes.ctVisa; icharge.Card.ExpMonth = 12; icharge.Card.ExpYear = 15; icharge.InvoiceNumber = "1234"; icharge.TransactionAmount = "1.00"; icharge.Config("FDMSTransArmorToken="+transArmorToken); icharge.Sale();

BASYS

// Note: A Customer Profile must be first created in order to generate a token. Recurringbilling recurring = new Recurringbilling(); string profileId; string token; recurring.Gateway = RecurringbillingGateways.gwBASYS; //This is your Username recurring.MerchantLogin = "Username"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantId"); //This will create a Customer Profile. recurring.Config("BASYSRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Generate a Token //This will generate a Token recurring.Config("BASYSRequestType=5"); recurring.Config("BASYSCustomerKey=" + profileId); recurring.Customer.Address = "123 Test St"; recurring.Customer.Zip = "12345"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; recurring.Config("BASYSTokenMode=1"); // Card Format Token try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //token was generated successfully token = recurring.Config("BASYSToken"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Token: " + token); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Process a transaction using the generated Token and the ICharge component Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwBASYS; //This is your Username icharge.MerchantLogin = "Username"; //This is your password icharge.MerchantPassword = "Password"; icharge.Config("BASYSProcessTokenCredit=True"); icharge.Config("BASYSTokenMode=1"); icharge.Config("BASYSToken=" + token); icharge.TransactionAmount = "1.00"; icharge.Sale(); if (icharge.Response.Approved) { //Response is approved, log approval code etc. Console.WriteLine("Approved: " + icharge.Response.ApprovalCode); } else { throw new Exception(icharge.Response.Text + ":" + icharge.Response.ErrorText); }

BlueSnap

BlueSnap provides a feature called “vaulted shopper profiles” which allow you to save payment information to customer profiles. Please refer to Working with BlueSnap Vaulted Shoppers for more information.

CyberSource

// Make a profile and return a token. Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwCyberSource; recurring.GatewayURL = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/"; recurring.MerchantLogin = "YourLogin"; recurring.MerchantPassword = "YourPassword"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 20; recurring.Card.CVVData = "123"; recurring.Customer.FirstName = "Steve"; recurring.Customer.LastName = "Rathmusen"; recurring.Customer.Address = "777 Lucky St."; recurring.Customer.City = "New York"; recurring.Customer.State = "NY"; recurring.Customer.Zip = "12345"; recurring.Customer.Country = "US"; recurring.Customer.Email = "steve.rathmusen@epicwidgets.com"; recurring.InvoiceNumber = "001"; // Profile ID (merchantReferenceCode) recurring.AddSpecialField("recurringSubscriptionInfo_frequency", "on-demand"); // Makes it a profile, rather than a subscription recurring.CreateSubscription(); // Token comes back as Profile/Sub/TransId string token = recurring.Response.SubscriptionId; // Make a transaction with the token Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwCyberSource; icharge.GatewayURL = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/"; icharge.MerchantLogin = "YourLogin"; icharge.MerchantPassword = "YourPassword"; icharge.InvoiceNumber = "12"; icharge.TransactionAmount = "4.59"; icharge.Config("CyberSourceProfileID=" + token); icharge.Sale(); Debug.WriteLine(icharge.Response.Approved ? "Success with a token!" : "Something went wrong: " + icharge.Config("RawResponse"));

Heartland

//set the component to retrieve a constant token icharge.Config("HeartlandTokenMapping=2"); //initial transaction icharge.Sale(); //retrieve the token string heartlandToken = icharge.Config("HeartlandToken"); //send a transaction using the token icharge.Config("HeartlandTokenMapping=0"); icharge.Config("HeartlandToken="+heartlandToken); icharge.InvoiceNumber = DateTime.Now.ToString(timeFormat); icharge.TransactionAmount = "1.00"; icharge.Sale();

GlobalOnePay

Recurringbilling rb = new Recurringbilling(); rb.Gateway = RecurringbillingGateways.gwGlobalOnePay; rb.Config("TerminalID=33001"); rb.Config("HashSecret=SandboxSecret001"); string tokenname = "NewToken"; // Must be unique rb.SubscriptionName = tokenname; rb.Card.ExpMonth = 12; rb.Card.ExpYear = 21; rb.Card.Number = "4444333322221111"; rb.Card.CVVData = "214"; rb.Customer.FullName = "John Smith"; rb.CreateSubscription(); string tokenid = rb.Response.SubscriptionId;

Global Payroll

Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwGlobalPayroll; icharge.GatewayURL = "http://demo.gpgway.com/gateway/GPGCCProcess.aspx"; //This is your APIUsername icharge.MerchantLogin = "demo"; //This is your APIPassword icharge.MerchantPassword = "password"; //This is your Client ID icharge.AddSpecialField("ClientID", "1009"); icharge.Card.Number = "4111111111111111"; icharge.Config("GlobalPayrollCreateToken"); string token = icharge.Config("GlobalPayrollToken");

Moneris

// Add a card to the vault: icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwMoneris; icharge.GatewayURL = "https://esqa.moneris.com/gateway2/servlet/MpgRequest"; icharge.MerchantLogin = "store5"; icharge.MerchantPassword = "yesguy"; icharge.Card.ExpMonth = 2; icharge.Card.ExpYear = 25; icharge.Card.Number = "5454545454545454"; string cardtoken = ""; icharge.Config("MonerisAddVault"); cardtoken = icharge.Config("CardToken"); // Use a card from the vault icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwMoneris; icharge.GatewayURL = "https://esqa.moneris.com/gateway2/servlet/MpgRequest"; icharge.MerchantLogin = "store5"; icharge.MerchantPassword = "yesguy"; icharge.InvoiceNumber = DateTime.Now.Ticks.ToString(); icharge.TransactionAmount = "1.00"; icharge.Config("CardToken=" + cardtoken); icharge.Sale();

Orbital

// Request the CustomerRefNum icharge.Config("OrbitalCustomerProfileFromOrderInd=A"); icharge.TransactionAmount = "100"; icharge.InvoiceNumber = "1234"; icharge.TransactionDesc = "Test Transaction"; icharge.Sale(); // Retrieve the token string customerRefNum = icharge.Customer.Id; // Clear card and customer values icharge.Card = new EPCard(); icharge.Customer = new EPCustomer(); icharge.Config("OrbitalCustomerProfileFromOrderInd="); // Send a transaction using the token icharge.Customer.Id = customerRefNum; icharge.TransactionAmount = "100"; icharge.InvoiceNumber = "1234"; icharge.TransactionDesc = "Test Token Transaction"; icharge.Sale();

PayFlow Pro

Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwPayFlowPro; icharge.GatewayURL = "https://pilot-payflowpro.paypal.com"; //test URL icharge.MerchantLogin = "YourMerchantLogin"; icharge.MerchantPassword = "YourMerchantPassword"; icharge.AddSpecialField("PARTNER", "VeriSign"); // Set up customer information. icharge.Customer.Address = "1234 Nowhere Ln"; icharge.Customer.City = "Beverly Hills"; icharge.Customer.Country = "US"; icharge.Customer.Email = "nobody@server.com"; icharge.Customer.FirstName = "John"; icharge.Customer.Id = "CUSTOMER1"; icharge.Customer.LastName = "Smith"; icharge.Customer.Phone = "555-555-5555"; icharge.Customer.State = "CA"; icharge.Customer.Zip = "90210"; // Add a card for the customer icharge.Card.Number = "4111111111111111"; icharge.Card.CVVPresence = CCCVVPresences.cvpProvided; icharge.Card.CVVData = "999"; icharge.Card.ExpMonth = 12; icharge.Card.ExpYear = 24; // Setting this config makes a $0 transaction, returning a token for later use. icharge.TransactionAmount = "0.00"; icharge.Config("PayFlowProUpload"); // The token will come back as the TransactionId. string token = icharge.Response.TransactionId; // Now perform a sale using the token returned previously. icharge.Config("PayFlowProToken=" + token); icharge.TransactionId = System.DateTime.Now.Millisecond.ToString(); icharge.TransactionAmount = "10.00"; icharge.InvoiceNumber = "9876"; // Make the sale and check the response icharge.Sale(); Console.WriteLine("Was the transaction approved? " + icharge.Response.Approved);

PayWiser

Recurringbilling recurring = new Recurringbilling(); string CardToken; string TokenReferenceId; recurring.Gateway = RecurringbillingGateways.gwPayWiser; recurring.GatewayURL = "https://gateway.paywiser.eu/PaymentGatewayTest/PayWiserPG/"; //This is your API Key recurring.MerchantLogin = "YourAPIKey"; recurring.Config("PayWiserRequestType=1"); //This will generate a Token recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; recurring.Card.CVVData = "999"; //This should be unique for each transaction recurring.TransactionId = "1001"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //Token was created successfully CardToken = recurring.Config("PayWiserCardToken"); TokenReferenceId = recurring.Config("PayWiserTokenReferenceId"); Console.WriteLine("Card Token: " + CardToken); Console.WriteLine("Token Reference Id: " + TokenReferenceId); } else { //There was an issue. throw new Exception(recurring.Response.ErrorText); } } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw; }

PhoeniXGate

// Note: A Customer Profile must be first created in order to generate a token. Recurringbilling recurring = new Recurringbilling(); string profileId; string token; recurring.Gateway = RecurringbillingGateways.gwPhoeniXGate; //This is your Username recurring.MerchantLogin = "Username"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantId"); //This will create a Customer Profile. recurring.Config("PhoeniXGateRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Generate a Token //This will generate a Token recurring.Config("PhoeniXGateRequestType=5"); recurring.Config("PhoeniXGateCustomerKey=" + profileId); recurring.Customer.Address = "123 Test St"; recurring.Customer.Zip = "12345"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; recurring.Config("PhoeniXGateTokenMode=1"); // Card Format Token try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //token was generated successfully token = recurring.Config("PhoeniXGateToken"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Token: " + token); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Process a transaction using the generated Token and the ICharge component Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwPhoeniXGate; //This is your Username icharge.MerchantLogin = "Username"; //This is your password icharge.MerchantPassword = "Password"; icharge.Config("PhoeniXGateProcessTokenCredit=True"); icharge.Config("PhoeniXGateTokenMode=1"); icharge.Config("PhoeniXGateToken=" + token); icharge.TransactionAmount = "1.00"; icharge.Sale(); if (icharge.Response.Approved) { //Response is approved, log approval code etc. Console.WriteLine("Approved: " + icharge.Response.ApprovalCode); } else { throw new Exception(icharge.Response.Text + ":" + icharge.Response.ErrorText); }

Repay

// Note. A Customer Profile must be first created in order to generate a token. Recurringbilling recurring = new Recurringbilling(); string profileId; string token; recurring.Gateway = RecurringbillingGateways.gwRepay; //This is your Username recurring.MerchantLogin = "Username"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantId"); //This will create a Customer Profile. recurring.Config("RepayRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Generate a Token //This will generate a Token recurring.Config("RepayRequestType=5"); recurring.Config("RepayCustomerKey=" + profileId); recurring.Customer.Address = "123 Test St"; recurring.Customer.Zip = "12345"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; recurring.Config("RepayTokenMode=1"); // Card Format Token try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //token was generated successfully token = recurring.Config("RepayToken"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Token: " + token); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Process a transaction using the generated Token and the ICharge component Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwRepay; //This is your Username icharge.MerchantLogin = "Username"; //This is your password icharge.MerchantPassword = "Password"; icharge.Config("RepayProcessTokenCredit=True"); icharge.Config("RepayTokenMode=1"); icharge.Config("RepayToken=" + token); icharge.TransactionAmount = "1.00"; icharge.Sale(); if (icharge.Response.Approved) { //Response is approved, log approval code etc. Console.WriteLine("Approved: " + icharge.Response.ApprovalCode); } else { throw new Exception(icharge.Response.Text + ":" + icharge.Response.ErrorText); }

SagePay

//NOTE: If AVS/CV2 is ON for your account, you will need to send CV2 // data with the transaction. You can bypass this restriction // if you call AddSpecialField("ApplyAVSCV2", "2") on the // component before submitting the transaction. //request the token icharge.TransactionAmount = "1.00"; icharge.TransactionDesc = "Token"; icharge.Config("SagePayRequestToken=True"); icharge.Config("SagePayStoreToken=True"); icharge.Sale(); //retrieving the token string token = icharge.Config("SagePayToken"); //using the token icharge.Config("SagePayToken=" + token); icharge.Config("SagePayRequestToken=False"); icharge.Config("SagePayStoreToken=True"); icharge.Sale();

Shift4

//initial transaction using card data icharge.Sale(); //retrieve the token string token = icharge.Config("CardToken"); //reset the card to avoid sending card data icharge.Card = new EPCard(); // send a transaction with the token icharge.TransactionAmount = "10.55"; icharge.TransactionId = "123456"; icharge.Config("CardToken=" + token); icharge.Sale();

Square

Tokenization is not optional when using the Square gateway, it does not allow passing raw card details. Refer the Square section of the “E-Payment Gateway Code Examples” KB article for a code example.

Square Payments

Tokenization is not optional when using the Square Payments gateway, it does not allow passing raw card details. Refer the Square Payments section of the “E-Payment Gateway Code Examples” KB article for a code example.

Stripe

//The ICharge component can only be used to charge a transaction with a token that //is already generated via "Stripe.js" client side javascript library. Icharge icharge = new Icharge(); icharge.Gateway = IchargeGateways.gwStripe; //This your API Key icharge.MerchantLogin = "YOUR API KEY"; //Test Visa Token from https://stripe.com/docs/testing icharge.Config("CardToken=tok_visa"); icharge.TransactionAmount = "100"; //100 means $1.00 icharge.Sale();

Worldpay Online

// Note that this example code shows how to use the ICharge component // to generate, update, and delete tokens; however, if your environment // is not PCI-compliant, you should instead use one of the libraries // that Worldpay provides to manipulate tokens. Refer to Worldpay's // documentation for more information. icharge.Gateway = IchargeGateways.gwWorldpayOnline; // The client key is used when generating and updating tokens. icharge.MerchantLogin = "Your CLIENT key"; icharge.Card.ExpMonth = 11; icharge.Card.ExpYear = 2025; icharge.Card.Number = "4444333322221111"; icharge.Card.CVVData = "123"; icharge.Customer.FullName = "John Doe"; icharge.Customer.Address = "123 Some Street"; icharge.Customer.Address2 = "Apt 456"; icharge.Customer.City = "Chapel Hill"; icharge.Customer.State = "NC"; icharge.Customer.Zip = "12345"; icharge.Customer.Country = "US"; icharge.Customer.Email = "johndoe@gmail.com"; // To generate a new token, set the "WorldpayOnlineTokenAction" config // to either 0 (to generate a single-use token), or 1 (to generate a // reusable token). We'll generate a reusable token for this example. icharge.Config("WorldpayOnlineTokenAction=1"); // The generated token is stored in the "WorldpayOnlineToken" config. // Now, we'll use the token to make a Sale transaction. Since there is // a token in the "WorldpayOnlineToken" config, it is sent instead of // the payment information. icharge.TransactionAmount = "100" // $1.00 // Note that, as with any transaction, you must use your SERVICE key! icharge.MerchantLogin = "Your SERVICE key"; icharge.Sale(); // Now, if this were a single-use token, you would not ever be able to // use it again. // We generated a reusable token, so we can reuse it. HOWEVER, we MUST // "update" the token with the CVC of the card it represents before // EVERY reuse, otherwise the transaction will fail. // To do this, supply the CVC and the token as usual (we already have // them set here) and set "WorldpayOnlineTokenAction" to 2. // As mentioned at the top of this example, you must use your CLIENT // key when updating tokens. icharge.MerchantLogin = "Your CLIENT key"; icharge.Config("WorldpayOnlineTokenAction=2"); // ...Now we could use it to make another transaction... // To delete a token (be it single-use or reusable), supply the token // and set "WorldpayOnlineTokenAction" to 3. // Once again, we must switch back to the SERVICE key to delete tokens. icharge.MerchantLogin = "Your SERVICE key"; icharge.Config("WorldpayOnlineTokenAction=3");

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@4dpayments.com.