public override void Close()
 {
     ikajo     = null;
     saleReq   = null;
     rebillReq = null;
     base.Close();
 }
        public override int GetToken(Payment payment)
        {
            string url = Tools.ConfigValue("SystemURL") + "/Succeed.aspx?TransRef=" + Tools.XMLSafe(payment.MerchantReference);
            int    ret = 300;

            Tools.LogInfo("TransactionIkajo.GetToken/10", "Sale, Merchant Ref=" + payment.MerchantReference, 199);

            try
            {
                string md5Signature = HashMD5(Tools.XMLSafe(payment.CardExpiryMM + payment.CardExpiryYY)
                                              + Tools.XMLSafe(payment.CardNumber)
                                              + Tools.XMLSafe(payment.CardType)
                                              + Tools.XMLSafe(payment.CardCVV)
                                              + Tools.XMLSafe(payment.Address1)
                                              + Tools.XMLSafe(payment.Address2)
                                              + Tools.XMLSafe(payment.CountryCode)
                                              + Tools.XMLSafe(payment.EMail)
                                              + Tools.XMLSafe(payment.IPAddress)
                                              + Tools.XMLSafe(payment.FirstName + " " + payment.LastName)
                                              + Tools.XMLSafe(payment.PhoneCell)
                                              + Tools.XMLSafe(payment.State)
                                              + Tools.XMLSafe(payment.PostalCode)
                                              + Tools.XMLSafe("YES")
                                              + Tools.XMLSafe(payment.ProviderUserID)
                                              + Tools.XMLSafe(payment.PaymentAmountDecimal)
                                              + Tools.XMLSafe(payment.CurrencyCode)
                                              + Tools.XMLSafe(payment.PaymentDescription)
                                              + Tools.XMLSafe(payment.MerchantReference)
                                              + Tools.XMLSafe(url)
                                              + Tools.XMLSafe(payment.ProviderPassword));

                if (saleReq == null)
                {
                    saleReq = new SaleRequest();
                }

                saleReq.cardExpiration       = Tools.XMLSafe(payment.CardExpiryMM + payment.CardExpiryYY);
                saleReq.cardNumber           = Tools.XMLSafe(payment.CardNumber);
                saleReq.cardType             = Tools.XMLSafe(payment.CardType);
                saleReq.cardVerificationCode = Tools.XMLSafe(payment.CardCVV);
                saleReq.customerAddress      = Tools.XMLSafe(payment.Address1);
                saleReq.customerCity         = Tools.XMLSafe(payment.Address2);
                saleReq.customerCountry      = Tools.XMLSafe(payment.CountryCode);
                saleReq.customerEmail        = Tools.XMLSafe(payment.EMail);
                saleReq.customerIP           = Tools.XMLSafe(payment.IPAddress);
                saleReq.customerName         = Tools.XMLSafe(payment.FirstName + " " + payment.LastName);
                saleReq.customerPhoneNumber  = Tools.XMLSafe(payment.PhoneCell);
                saleReq.customerState        = Tools.XMLSafe(payment.State);
                saleReq.customerZipCode      = Tools.XMLSafe(payment.PostalCode);
                saleReq.initRecurring        = "YES";
                saleReq.merchantID           = Tools.XMLSafe(payment.ProviderUserID);
                saleReq.orderAmount          = Tools.XMLSafe(payment.PaymentAmountDecimal);
                saleReq.orderCurrency        = Tools.XMLSafe(payment.CurrencyCode);
                saleReq.orderDescription     = Tools.XMLSafe(payment.PaymentDescription);
                saleReq.orderReference       = Tools.XMLSafe(payment.MerchantReference);
                saleReq.returnUrl            = Tools.XMLSafe(url);
                saleReq.signature            = md5Signature;

                Tools.LogInfo("TransactionIkajo.GetToken/20", "", 10);

                if (ikajo == null)
                {
                    ikajo = new PtCardService();
                }

                PCIBusiness.IkajoService.SaleResult result = ikajo.sale(saleReq);
                string x = "[TokenResult] StatusCode=" + result.statusCode
                           + " | TransactionStatus=" + result.transactionStatus
                           + " | TransactionError=" + result.transactionError
                           + " | RecurringToken=" + result.recurringToken;

                Tools.LogInfo("TransactionIkajo.GetToken/30", x, 10);

                payToken   = result.recurringToken;
                payRef     = result.orderReference;
                resultCode = result.transactionStatus;
                resultMsg  = result.transactionError;

//				if ( ret != 0 )
//					Tools.LogInfo("TransactionIkajo.GetToken/50","ResultCode="+ResultCode + ", payToken=" + payToken,220);
            }
            catch (Exception ex)
            {
                Tools.LogInfo("TransactionIkajo.GetToken/98", "Ret=" + ret.ToString() + ", XML Sent=" + xmlSent, 255);
                Tools.LogException("TransactionIkajo.GetToken/99", "Ret=" + ret.ToString() + ", XML Sent=" + xmlSent, ex);
            }
            return(ret);
        }