public override void Close()
 {
     myGateToken = null;
     myGatePay   = null;
     results     = null;
     resultLine  = null;
     base.Close();
 }
        public override int TokenPayment(Payment payment)
        {
            if (!EnabledFor3d(payment.TransactionType))
            {
                return(590);
            }

            int ret = 600;

            xmlSent = "";

            try
            {
                ret     = 610;
                xmlSent = "<?xml version='1.0' encoding='utf-16'?>"
                          + "<debitorder>"
                          + "<header>"
                          + "<merchantno>" + payment.ProviderAccount + "</merchantno>"                 // merchant account number, NOT MID
                          + "<applicationid>" + payment.ProviderKey + "</applicationid>"
                          + "<servicetype>1</servicetype>"
                          + "<totaltransactions>1</totaltransactions>"
                          + "<firstactiondate>" + Tools.DateToString(System.DateTime.Now, 9) + "</firstactiondate>"                // yymmdd
                          + "<lastactiondate>" + Tools.DateToString(System.DateTime.Now, 9) + "</lastactiondate>"
                          + "<merchantcellnotify/>"
                          + "<merchantemailnotify/>"
                          + "</header>"
                          + "<transaction>"
                          + "<sequenceno>1</sequenceno>"
                          + "<clientpin>" + payment.CardPIN + "</clientpin>"
                          + "<clientuci>" + payment.CardPIN + "</clientuci>"
                          + "<clientuid>" + payment.CardToken + "</clientuid>"
                          + "<debitamount>" + payment.PaymentAmountDecimal + "</debitamount>"
                          + "<debitdate>" + Tools.DateToString(System.DateTime.Now, 9) + "</debitdate>"
                          + "<debitreference>" + payment.PaymentDescription.Substring(0, 13) + "</debitreference>"
                          + "<debitcellnotify/>"
                          + "<debitemailnotify/>"
                          + "<transactionrefno>" + payment.MerchantReference + "</transactionrefno>"
                          + "</transaction>"
                          + "<footer>"
                          + "<totaltransactions>1</totaltransactions>"
                          + "<firstactiondate>" + Tools.DateToString(System.DateTime.Now, 9) + "</firstactiondate>"
                          + "<lastactiondate>" + Tools.DateToString(System.DateTime.Now, 9) + "</lastactiondate>"
                          + "<debittotal>" + payment.PaymentAmountDecimal + "</debittotal>"
                          + "</footer>"
                          + "</debitorder>";

                if (myGatePay == null)
                {
                    myGatePay = new MyGatePayment.MyGate_DebitOrder_WebServiceService();
                }

                ret       = 620;
                xmlResult = null;
                strResult = "";

                Tools.LogInfo("TokenPayment/20", "uploadDebitFile(\"" + xmlSent + "\")", 10, this);

                ret       = 630;
                strResult = myGatePay.uploadDebitFile(xmlSent);

                Tools.LogInfo("TokenPayment/30", "Result=" + strResult, 10, this);
            }
            catch (Exception ex)
            {
                Tools.LogInfo("TokenPayment/98", "Ret=" + ret.ToString() + ", XML Sent=" + xmlSent, 255, this);
                Tools.LogException("TokenPayment/99", "Ret=" + ret.ToString() + ", XML Sent=" + xmlSent, ex, this);
            }
            return(ret);
        }