Knowledge Base

Get help for payment solutions. Search our articles or browse by category below.

.NET XML Secure Cards

The sample code below require the .NET XML API.

SecureCard registration:

using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using WorldnetClient;
 
namespace ApiTest
{
    class Program
    {
        static void Main(string[] args)
        {
            String gateway = "";		// Gateway that will process the transaction. "worldnet" or "cashflows"
            String terminalId = "";		// Terminal ID Supplied by WorldNet
            String secret = "";			// Shared Secret as configured in the Terminal Setup in your WoldNet SelfCare System
 
            String secureCardMerchantRef = "";	// Unique Merchant Reference. Length is limited to 48 chars.
            String cardNumber = "";		// The cardholders PAN (or SecureCard Card Reference);
            String cardType = "";		// See our Integrator Guide for a list of valid Card Type parameters
            String cardHolderName = "";		// Cardholders name
 
            String dontCheckSecurity = "";	// (optional) "Y" if you do not want the CVV to be validated online.
            String cvv = "";			// (optional) 3 digit (4 for AMEX cards) security digit on the back of the card.
            String issueNo = "";		// (optional) Issue number for Switch and Solo cards.
 
            Boolean testAccount = true;
 
            XmlSecureCardRegRequest securereg = new XmlSecureCardRegRequest(secureCardMerchantRef, terminalId, cardNumber, cardExpiry, cardType, cardHolderName);
 
            if (!String.IsNullOrEmpty(dontCheckSecurity)) { securereg.SetDontCheckSecurity(dontCheckSecurity); }
            if (!String.IsNullOrEmpty(cvv)) { securereg.SetCvv(cvv); }
            if (!String.IsNullOrEmpty(issueNo)) { securereg.SetIssueNo(issueNo); }
 
            XmlSecureCardRegResponse response = securereg.ProcessRequest(secret, testAccount, gateway);
 
            String expectedResponseHash = Response.GetResponseHash(terminalId + response.MerchantRef + response.CardRef + response.DateTimeHashString + secret);
 
            if (response.IsError == true)
            {
                Console.Out.WriteLine("ERROR : " + response.ErrorString);
                //Handle Error Response
            }
            else if (response.Hash != expectedResponseHash)
            {
                Console.Out.WriteLine("ERROR : Response HASH parameter not as expected. If live possible man-in-the-middle attack.");
                //Handle Invalid Hash scenario - inform merchant that transaction may have to be voided.
            }
            else
            {
                Console.Out.WriteLine("SecureCard successfully stored.");
                Console.Out.WriteLine("CARDREFERENCE : " + response.CardRef);
                //Handle Response
            }
        }
    }
}

SecureCard record update:

using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using WorldnetClient;
 
namespace ApiTest
{
    class Program
    {
        static void Main(string[] args)
        {
            String gateway = "";		// Gateway that will process the transaction. "worldnet" or "cashflows"
            String terminalId = "";		// Terminal ID Supplied by WorldNet
            String secret = "";			// Shared Secret as configured in the Terminal Setup in your WoldNet SelfCare System
 
            String secureCardMerchantRef = "";	// Unique Merchant Reference. Length is limited to 48 chars.
            String cardNumber = "";		// The cardholders PAN (or SecureCard Card Reference);
            String cardType = "";		// See our Integrator Guide for a list of valid Card Type parameters
            String cardHolderName = "";		// Cardholders name
 
            String dontCheckSecurity = "";	// (optional) "Y" if you do not want the CVV to be validated online.
            String cvv = "";			// (optional) 3 digit (4 for AMEX cards) security digit on the back of the card.
            String issueNo = "";		// (optional) Issue number for Switch and Solo cards.
 
            Boolean testAccount = true;
 
            XmlSecureCardUpdRequest secureupd = new XmlSecureCardUpdRequest(secureCardMerchantRef, terminalId, cardNumber, cardExpiry, cardType, cardHolderName);
 
            if (!String.IsNullOrEmpty(dontCheckSecurity)) { secureupd.SetDontCheckSecurity(dontCheckSecurity); }
            if (!String.IsNullOrEmpty(cvv)) { secureupd.SetCvv(cvv); }
            if (!String.IsNullOrEmpty(issueNo)) { secureupd.SetIssueNo(issueNo); }
 
            XmlSecureCardUpdResponse response = secureupd.ProcessRequest(secret, testAccount, gateway);
 
            String expectedResponseHash = Response.GetResponseHash(terminalId + response.MerchantRef + response.CardRef + response.DateTimeHashString + secret);
 
            if (response.IsError == true)
            {
                Console.Out.WriteLine("ERROR : " + response.ErrorString);
                //Handle Error Response
            }
            else if (response.Hash != expectedResponseHash)
            {
                Console.Out.WriteLine("ERROR : Response HASH parameter not as expected. If live possible man-in-the-middle attack.");
                //Handle Invalid Hash scenario - inform merchant that transaction may have to be voided.
            }
            else
            {
                Console.Out.WriteLine("SecureCard successfully updated.");
                //Handle Response
            }
        }
    }
}

SecureCard record deletion:

using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using WorldnetClient;
 
namespace ApiTest
{
    class Program
    {
        static void Main(string[] args)
        {
            String gateway = "";		// Gateway that will process the transaction. "worldnet" or "cashflows"
            String terminalId = "";		// Terminal ID Supplied by WorldNet
            String secret = "";			// Shared Secret as configured in the Terminal Setup in your WoldNet SelfCare System
 
            String secureCardMerchantRef = "";	// Unique Merchant Reference. Length is limited to 48 chars.
            String secureCardCardRef = "";	// This is the WorldNet generated 16 digit card number token
 
            Boolean testAccount = true;
 
            XmlSecureCarDelRequest securedel = new XmlSecureCarDelRequest(secureCardMerchantRef, terminalId, secureCardCardRef);
            XmlSecureCarDelResponse response = securedel.ProcessRequest(secret, testAccount, gateway);
 
            String expectedResponseHash = Response.GetResponseHash(terminalId + response.MerchantRef + response.DateTimeHashString + secret);
 
            if (response.IsError == true)
            {
                Console.Out.WriteLine("ERROR : " + response.ErrorString);
                //Handle Error Response
            }
            else if (response.Hash != expectedResponseHash)
            {
                Console.Out.WriteLine("ERROR : Response HASH parameter not as expected. If live possible man-in-the-middle attack.");
                //Handle Invalid Hash scenario - inform merchant that transaction may have to be voided.
            }
            else
            {
                Console.Out.WriteLine("SecureCard successfully deleted.");
                //Handle Response
            }
        }
    }
}

SecureCard Search:

using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using WorldnetClient;
 
namespace ApiTest
{
    class Program
    {
        static void Main(string[] args)
        {
            String gateway = "";		// Gateway that will process the transaction. "worldnet" or "cashflows"
            String terminalId = "";		// Terminal ID Supplied by WorldNet
            String secret = "";			// Shared Secret as configured in the Terminal Setup in your WoldNet SelfCare System
 
            String secureCardMerchantRef = "";	// Unique Merchant Reference. Length is limited to 48 chars.
 
            Boolean testAccount = true;
 
            XmlSecureCardSearchRequest securesearch = new XmlSecureCardSearchRequest(secureCardMerchantRef, terminalId);
            XmlSecureCardSearchResponse response = securesearch.ProcessRequest(secret, testAccount, gateway);
 
            String expectedResponseHash = Response.GetResponseHash(terminalId + response.MerchantRef + response.CardRef + response.CardType + response.CardExpiry + response.CardHolderName + response.DateTimeHashString + secret);
 
            if (response.IsError == true)
            {
                Console.Out.WriteLine("ERROR : " + response.ErrorString);
                //Handle Error Response
            }
            else if (response.Hash != expectedResponseHash)
            {
                Console.Out.WriteLine("ERROR : Response HASH parameter not as expected. If live possible man-in-the-middle attack.");
                //Handle Invalid Hash scenario - inform merchant that transaction may have to be voided.
            }
            else
            {
                Console.Out.WriteLine("SecureCard successfully found.");
                Console.Out.WriteLine("MERCHANTREF : " + response.MerchantRef);
                Console.Out.WriteLine("CARDREFERENCE : " + response.CardRef);
                Console.Out.WriteLine("CARDTYPE : " + response.CardType);
                Console.Out.WriteLine("CARDEXPIRY : " + response.CardExpiry);
                Console.Out.WriteLine("CARDHOLDERNAME : " + response.CardHolderName);
                //Handle Response
            }
        }
    }
}
Copyright © 2017 Worldnet Knowledge Base | Powered by DokuWiki
developer/sample_codes/net_xml_secure_cards.txt · Last modified: 2016/07/26 10:55 (external edit)