public override void Close()
 {
     myGateToken = null;
     myGatePay   = null;
     results     = null;
     resultLine  = null;
     base.Close();
 }
        public override int GetToken(Payment payment)
        {
            int ret = 300;

            try
            {
                if (myGateToken == null)
                {
                    myGateToken = new MyGateToken.PinManagement();
                }

                ret       = 310;
                xmlResult = null;
                strResult = "";
                xmlSent   = "fLoadPinCC ( '" + payment.ProviderUserID + "'"
                            + ", '" + payment.ProviderKey + "'"
                            + ", '" + payment.CardNumber + "'"
                            + ", '" + payment.CardName + "'"
                            + ", '" + payment.CardExpiryMM + "'"
                            + ", '" + payment.CardExpiryYYYY + "'"
                            + ", '" + payment.CardType + "'"
                            + ", '" + payment.CardPIN + "'"
                            + ", '" + payment.MerchantReference + "' )";

                Tools.LogInfo("GetToken/10", xmlSent, 10, this);

                ret     = 315;
                results = myGateToken.fLoadPinCC(payment.ProviderUserID,
                                                 payment.ProviderKey,
                                                 payment.CardNumber,
                                                 payment.CardName,
                                                 payment.CardExpiryMM,
                                                 payment.CardExpiryYYYY,
                                                 payment.CardType,
                                                 payment.CardPIN,
                                                 payment.MerchantReference);

//				object[] fLoadPinCC(string ClientID, string ApplicationID, string CardNumber, string CardHolder, string ExpiryMonth, string ExpiryYear, string CardType, string ClientPin, string ClientUCI);

                ret = 320;
                for (int k = 0; k < results.Length; k++)
                {
                    strResult = strResult + " [" + results[k].ToString().Trim() + "]";
                }
                strResult = strResult.Trim();

                ret        = 325;
                resultLine = results[1].ToString().Split(new string[] { "||" }, StringSplitOptions.None);
                ret        = 330;
                payRef     = resultLine[1];                 // TransactionIndex
                payToken   = resultLine[1];
                resultCode = "0";
                resultMsg  = "";
                ret        = 340;
                resultLine = results[0].ToString().Split(new string[] { "||" }, StringSplitOptions.None);
                ret        = 350;

                if (resultLine[1] == "0")                   // All OK
                {
                    return(0);
                }

                ret        = 360;
                resultLine = results[2].ToString().Split(new string[] { "||" }, StringSplitOptions.None);
                ret        = 370;
                resultCode = resultLine[1];
                ret        = 380;
                resultMsg  = resultLine[3] + (resultLine[4].Length > 0 ? " (" + resultLine[4] + ")" : "");

                Tools.LogInfo("GetToken/20", "ResultCode=" + resultCode + ", Message=" + resultMsg, 10, this);
            }
            catch (Exception ex)
            {
                Tools.LogInfo("GetToken/98", "Ret=" + ret.ToString() + ", " + xmlSent, 255, this);
                Tools.LogException("GetToken/99", "Ret=" + ret.ToString() + ", " + xmlSent, ex, this);
            }
            return(ret);
        }