/// <summary> /// Captures payment /// </summary> /// <param name="capturePaymentRequest">Capture payment request</param> /// <returns>Capture payment result</returns> public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest) { var result = new CapturePaymentResult(); // Check license bool isLicensed = this._licenseService.IsLicensed(HttpContext.Current.Request.Url.Host); if (!isLicensed && capturePaymentRequest.Order.OrderTotal > 5.00M) { result.AddError("The trial license can be used to submit order of $5.00 or less. Please purchase a full license at our website."); return result; } string authorizationId = capturePaymentRequest.Order.AuthorizationTransactionId; // Create the Payflow Data Objects. // Create the User data object with the required user details. UserInfo payflowUser = _payPalHelper.GetUserInfo(); // Create the Payflow Connection data object with the required connection details. PayflowConnectionData payflowConn = new PayflowConnectionData(_payPalHelper.GetPayflowProHost()); CaptureTransaction trans = new CaptureTransaction(authorizationId, payflowUser, payflowConn, PayflowUtility.RequestId); Response resp = trans.SubmitTransaction(); // Process the Payflow response. if (resp != null) { // Get the Transaction Response parameters. TransactionResponse trxResp = resp.TransactionResponse; if (trxResp != null) { if (trxResp.Result == 0) { result.NewPaymentStatus = PaymentStatus.Paid; result.CaptureTransactionId = trxResp.Pnref; result.CaptureTransactionResult = trxResp.RespMsg; } else { result.AddError(string.Format("Capture RESULT: {0}-{1}", trxResp.Result, trxResp.RespMsg)); } } } return result; }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DOCapture.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(); /////////////////////////////////////////////////////////////////// // If you want to change the amount being captured, you'll need to set the Amount object. // Invoice Inv = new Invoice(); // Set the amount object if you want to change the amount from the original authorization. // Currency Code USD is US ISO currency code. If no code passed, USD is default. // See the Developer//s Guide for the list of three-character currency codes available. // Currency Amt = new Currency(new decimal(25.12)); // Inv.Amt = Amt; // CaptureTransaction Trans = new CaptureTransaction("<ORIGINAL_PNREF>", User, Connection, Inv, PayflowUtility.RequestId); // Create a new Capture Transaction for the original amount of the authorization. See above if you // need to change the amount. CaptureTransaction Trans = new CaptureTransaction("<ORIGINAL_PNREF>", User, Connection, PayflowUtility.RequestId); // Indicates if this Delayed Capture transaction is the last capture you intend to make. // The values are: Y (default) / N // NOTE: If CAPTURECOMPLETE is Y, any remaining amount of the original reauthorized transaction // is automatically voided. Also, this is only used for UK and US accounts where PayPal is acting // as your bank. // Trans.CaptureComplete = "N"; // Set the transaction verbosity to HIGH to display most details. 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("AVSADDR = " + TrxnResponse.AVSAddr); Console.WriteLine("AVSZIP = " + TrxnResponse.AVSZip); Console.WriteLine("IAVS = " + TrxnResponse.IAVS); // If value is true, then the Request ID has not been changed and the original response // of the original transction is returned. Console.WriteLine("DUPLICATE = " + TrxnResponse.Duplicate); } // Get the Fraud Response parameters. FraudResponse FraudResp = Resp.FraudResponse; // Display Fraud Response parameter if (FraudResp != null) { Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); } // Display the response. Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); // 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(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); } } Console.WriteLine("Press Enter to Exit ..."); Console.ReadLine(); }
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(); }