Ejemplo n.º 1
0
        public static void Main(string[] Args)
        {
            Console.WriteLine("---------------------------------------------------------");
            Console.WriteLine("Executing Sample from File: DO_TeleCheck.cs");
            Console.WriteLine("---------------------------------------------------------");

            // Create the Data Objects.
            // Create the User data object with the required user details.
            UserInfo User = new UserInfo("<user>", "<vendor>", "<partner>", "<password>");

            // Create the Payflow  Connection data object with the required connection details.
            // The PAYFLOW_HOST property is defined in the App config file.
            PayflowConnectionData Connection = new PayflowConnectionData();

            // Create a new Invoice data object with the Amount, Billing Address etc. details.
            Invoice Inv = new Invoice();

            // Set Amount.
            Currency Amt = new Currency(new decimal(25.12));

            Inv.Amt    = Amt;
            Inv.PoNum  = "PO12345";
            Inv.InvNum = "INV12345";

            // Set the Billing Address details.
            BillTo Bill = new BillTo();

            Bill.BillToStreet  = "123 Main St.";
            Bill.BillToZip     = "12345";
            Bill.BillToCity    = "New York";
            Bill.BillToState   = "PA";
            Bill.BillToZip     = "12345";
            Bill.BillToPhone   = "123-4546-7890";
            Bill.BillToEmail   = "*****@*****.**";
            Bill.BillToCountry = "US";
            Inv.BillTo         = Bill;

            // Set the IP address of the customer
            CustomerInfo custInfo = new CustomerInfo();

            custInfo.CustIP  = "111.111.11.111";
            Inv.CustomerInfo = custInfo;

            // Create a new Payment Device - Check Payment data object.
            // The input parameters is MICR. Magnetic Ink Check Reader. This is the entire line
            // of numbers at the bottom of all checks. It includes the transit number, account
            // number, and check number.
            CheckPayment ChkPayment = new CheckPayment("1234567804390850001234");

            // Name property needs to be set for the Check Payment.
            ChkPayment.Name = "Ivan Smith";
            // Create a new Tender - Check Tender data object.
            CheckTender ChkTender = new CheckTender(ChkPayment);

            // Account holder’s next unused (available) check number. Up to 7 characters.
            ChkTender.ChkNum = "1234";
            // DL or SS is required for a TeleCheck transaction.
            // If CHKTYPE=P, a value for either DL or SS must be passed as an identifier.
            // If CHKTYPE=C, the Federal Tax ID must be passed as the SS value.
            ChkTender.ChkType = "P";
            // Driver’s License number. If CHKTYPE=P, a value for either DL or SS must be passed as an identifier.
            // Format: XXnnnnnnnn
            // XX = State Code, nnnnnnnn = DL Number - up to 31 characters.
            ChkTender.DL = "CAN85452345";
            // Social Security number.  Needed if ChkType = P
            ChkTender.SS = "456765833";
            // AuthType = I-Internet Check, P-Checks by Phone, D-Prearranged Deposit
            ChkTender.AuthType = "I";

            // Create a new TeleCheck - Authorization Transaction.
            AuthorizationTransaction Trans = new AuthorizationTransaction(
                User, Connection, Inv, ChkTender, PayflowUtility.RequestId);

            //Want VERBOSITY=HIGH to get all the response values back.
            Trans.Verbosity = "HIGH";

            // Submit the Transaction
            Response Resp = Trans.SubmitTransaction();

            // Display the transaction response parameters.
            if (Resp != null)
            {
                // Get the Transaction Response parameters.
                TransactionResponse TrxnResponse = Resp.TransactionResponse;
                if (TrxnResponse != null)
                {
                    Console.WriteLine("RESULT = " + TrxnResponse.Result);
                    Console.WriteLine("PNREF = " + TrxnResponse.Pnref);
                    Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg);
                    Console.WriteLine("AUTHCODE = " + TrxnResponse.AuthCode);
                    Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode);
                    Console.WriteLine("TRACEID = " + TrxnResponse.TraceId);
                    Console.WriteLine("ACHSTATUS = " + TrxnResponse.AchStatus);
                }
                // Display the response.
                Console.WriteLine(PayflowUtility.GetStatus(Resp) + Environment.NewLine);
                // Get the Transaction Context and check for any contained SDK specific errors (optional code).
                Context TransCtx = Resp.TransactionContext;
                if (TransCtx != null && TransCtx.getErrorCount() > 0)
                {
                    Console.WriteLine("Transaction Errors = " + TransCtx.ToString() + Environment.NewLine);
                }
                if (TrxnResponse.Result == 0)
                {
                    // Transaction approved, display acceptance verbiage, after consumer accepts, capture the
                    // transaction to finalize it.
                    CaptureTransaction capTrans = new CaptureTransaction(TrxnResponse.Pnref, User, Connection, null, ChkTender, PayflowUtility.RequestId);
                    // Set the transaction verbosity to HIGH to display most details.
                    capTrans.Verbosity = "HIGH";

                    // Submit the Transaction
                    Response capResp = capTrans.SubmitTransaction();

                    // Display the transaction response parameters.
                    if (capResp != null)
                    {
                        // Get the Transaction Response parameters.
                        TransactionResponse capTrxnResponse = capResp.TransactionResponse;
                        if (capTrxnResponse != null)
                        {
                            Console.WriteLine("RESULT = " + capTrxnResponse.Result);
                            Console.WriteLine("PNREF = " + capTrxnResponse.Pnref);
                            Console.WriteLine("RESPMSG = " + capTrxnResponse.RespMsg);
                            Console.WriteLine("HOSTCODE = " + capTrxnResponse.HostCode);
                            Console.WriteLine("TRACEID = " + capTrxnResponse.TraceId);
                        }
                        // Display the response.
                        Console.WriteLine(PayflowUtility.GetStatus(capResp) + Environment.NewLine);
                        // Get the Transaction Context and check for any contained SDK specific errors (optional code).
                        Context capTransCtx = capResp.TransactionContext;
                        if (capTransCtx != null && capTransCtx.getErrorCount() > 0)
                        {
                            Console.WriteLine("Transaction Errors = " + capTransCtx.ToString() + Environment.NewLine);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Unable to capture transaction as it declined or failed." + Environment.NewLine);
                    }
                }
            }
            Console.WriteLine("Press Enter to Exit ...");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public PaymentResponse BusinessCheckPayment(BusinessCheckPaymentRequest req)
        {
            var     resp      = new PaymentResponse();
            Invoice Inv       = new Invoice();
            var     RequestID = PayflowUtility.RequestId;
            PayflowConnectionData Connection = new PayflowConnectionData(Host, Port, Timeout, "", 0, "", "");
            int  trxCount = 1;
            bool RespRecd = false;

            Currency Amt = new Currency(req.Amount);

            Amt.NoOfDecimalDigits = 0;
            Inv.Amt      = Amt;
            Inv.InvNum   = req.InvoiceNumber;
            Inv.Comment1 = req.Comment;

            // Create the BillTo object.
            Inv.BillTo = CreateBillTo(req.BillingInformation);

            // Create Credit Card data object.
            var payment = new PayPal.Payments.DataObjects.CheckPayment(req.RoutingNumber + req.AccountNumber + req.CheckNumber);

            // Create Card Tender data object.
            var tender = new CheckTender(payment)
            {
                ChkType = "C",
                SS      = req.EIN_SSN,
                ChkNum  = req.CheckNumber
            };


            UserInfo TeleCheckUser = new UserInfo(User, Vendor, Partner, Password);

            // Notice we set the request id earlier in the application and outside our loop.  This way if a response was not received
            // but PayPal processed the original request, you'll receive the original response with DUPLICATE set.
            AuthorizationTransaction Trans = new AuthorizationTransaction(TeleCheckUser, Connection, Inv, tender, RequestID);

            Trans.AddToExtendData(new ExtendData("AUTHTYPE", "I"));
            Trans.AddToExtendData(new ExtendData("CUSTIP", req.IPAddress));

            Trans.Verbosity = String.IsNullOrEmpty(Verbosity)? "HIGH" : Verbosity;


            while (trxCount <= 3 && !RespRecd)
            {
                Response Resp = Trans.SubmitTransaction();
                if (Resp != null)
                {
                    RespRecd = true;  // Got a response.
                    TransactionResponse TrxnResponse = Resp.TransactionResponse;
                    if (TrxnResponse != null)
                    {
                        resp = ProcessTransaction(TrxnResponse);
                    }
                }
                else
                {
                    trxCount++;
                }
            }

            if (!RespRecd)
            {
                resp.Success = false;
                resp.Message = "Payment not processed.  Please contact Customer Service";
            }

            return(resp);
        }