public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DORecurringReActivate.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(); RecurringInfo RecurInfo = new RecurringInfo(); RecurInfo.OrigProfileId = "<PROFILE_ID>"; // RT0000001350 // The date that the first payment will be processed. // This will be of the format mmddyyyy. RecurInfo.Start = "01012009"; // Create a new Recurring ReActivate Transaction. RecurringReActivateTransaction Trans = new RecurringReActivateTransaction( User, Connection, RecurInfo, PayflowUtility.RequestId); // 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("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { Console.WriteLine("RPREF = " + RecurResponse.RPRef); Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); } // 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(); }
/// <summary> /// Updates the scheduled payment. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="paymentInfo">The payment info.</param> /// <param name="errorMessage">The error message.</param> /// <returns></returns> public override bool UpdateScheduledPayment(FinancialScheduledTransaction transaction, PaymentInfo paymentInfo, out string errorMessage) { errorMessage = string.Empty; RecurringModifyTransaction ppTransaction = null; var financialGateway = GetFinancialGateway(transaction); if (paymentInfo != null) { ppTransaction = new RecurringModifyTransaction(GetUserInfo(financialGateway), GetConnection(financialGateway), GetRecurring(transaction), GetInvoice(paymentInfo), GetTender(paymentInfo), PayflowUtility.RequestId); } else { ppTransaction = new RecurringModifyTransaction(GetUserInfo(financialGateway), GetConnection(financialGateway), GetRecurring(transaction), PayflowUtility.RequestId); } var ppResponse = ppTransaction.SubmitTransaction(); if (ppResponse != null) { TransactionResponse txnResponse = ppResponse.TransactionResponse; if (txnResponse != null) { if (txnResponse.Result == 0) // Success { RecurringResponse recurringResponse = ppResponse.RecurringResponse; if (recurringResponse != null) { return(true); } else { errorMessage = "Invalid recurring response from the financial gateway"; } } else { errorMessage = string.Format("[{0}] {1}", txnResponse.Result, txnResponse.RespMsg); } } else { errorMessage = "Invalid transaction response from the financial gateway"; } } else { errorMessage = "Invalid response from the financial gateway."; } return(false); }
private string BuildRecurringResponseDebug(RecurringResponse response) { StringBuilder sb = new StringBuilder(); sb.Append("\r\nParadata PayGateway.RecurringResponse Object\r\n"); sb.Append("ResponseCode=" + response.getResponseCode() + "\r\n"); sb.Append("ResponseCodeText=" + response.getResponseCodeText() + "\r\n"); sb.Append("SecondaryResponseCode=" + response.getSecondaryResponseCode() + "\r\n"); sb.Append("TimeStamp=" + response.getTimeStamp() + "\r\n"); //sb.Append("responseString=" + response.responseString + "\r\n"); return(sb.ToString()); }
/// <summary> /// Gets the scheduled payment status. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="errorMessage">The error message.</param> /// <returns></returns> public override bool GetScheduledPaymentStatus(FinancialScheduledTransaction transaction, out string errorMessage) { errorMessage = string.Empty; var financialGateway = GetFinancialGateway(transaction); var ppTransaction = new RecurringInquiryTransaction(GetUserInfo(financialGateway), GetConnection(financialGateway), GetRecurring(transaction), PayflowUtility.RequestId); var ppResponse = ppTransaction.SubmitTransaction(); if (ppResponse != null) { TransactionResponse txnResponse = ppResponse.TransactionResponse; if (txnResponse != null) { if (txnResponse.Result == 0) // Success { RecurringResponse recurringResponse = ppResponse.RecurringResponse; if (recurringResponse != null) { transaction.IsActive = recurringResponse.Status.ToUpper() == "ACTIVE"; transaction.StartDate = GetDate(recurringResponse.Start) ?? transaction.StartDate; transaction.NextPaymentDate = GetDate(recurringResponse.NextPayment) ?? transaction.NextPaymentDate; transaction.NumberOfPayments = recurringResponse.Term.AsIntegerOrNull() ?? transaction.NumberOfPayments; transaction.LastStatusUpdateDateTime = RockDateTime.Now; transaction.StatusMessage = recurringResponse.Status; transaction.Status = GetFinancialScheduledTransactionStatus(recurringResponse); return(true); } return(true); } else { errorMessage = string.Format("[{0}] {1}", txnResponse.Result, txnResponse.RespMsg); } } else { errorMessage = "Invalid transaction response from the financial gateway"; } } else { errorMessage = "Invalid response from the financial gateway."; } return(false); }
/// <summary> /// Reactivates the scheduled payment. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="paymentInfo">The payment information.</param> /// <param name="errorMessage">The error message.</param> /// <returns></returns> public override bool ReactivateScheduledPayment(FinancialScheduledTransaction transaction, out string errorMessage) { errorMessage = string.Empty; var ppTransaction = new RecurringReActivateTransaction(GetUserInfo(), GetConnection(), GetRecurring(transaction), PayflowUtility.RequestId); var ppResponse = ppTransaction.SubmitTransaction(); if (ppResponse != null) { TransactionResponse txnResponse = ppResponse.TransactionResponse; if (txnResponse != null) { if (txnResponse.Result == 0) // Success { RecurringResponse recurringResponse = ppResponse.RecurringResponse; if (recurringResponse != null) { return(true); } else { errorMessage = "Invalid recurring response from the financial gateway"; } } else { errorMessage = string.Format("[{0}] {1}", txnResponse.Result, txnResponse.RespMsg); } } else { errorMessage = "Invalid transaction response from the financial gateway"; } } else { errorMessage = "Invalid response from the financial gateway."; } return(false); }
/// <summary> /// Adds the scheduled payment. /// </summary> /// <param name="financialGateway"></param> /// <param name="schedule">The schedule.</param> /// <param name="paymentInfo">The payment info.</param> /// <param name="errorMessage">The error message.</param> /// <returns></returns> public override FinancialScheduledTransaction AddScheduledPayment(FinancialGateway financialGateway, PaymentSchedule schedule, PaymentInfo paymentInfo, out string errorMessage) { errorMessage = string.Empty; var recurring = GetRecurring(schedule); if (paymentInfo is CreditCardPaymentInfo) { recurring.OptionalTrx = "A"; } var ppTransaction = new RecurringAddTransaction(GetUserInfo(financialGateway), GetConnection(financialGateway), GetInvoice(paymentInfo), GetTender(paymentInfo), recurring, PayflowUtility.RequestId); if (paymentInfo is ReferencePaymentInfo) { var reference = paymentInfo as ReferencePaymentInfo; ppTransaction.OrigId = reference.TransactionCode; } var ppResponse = ppTransaction.SubmitTransaction(); if (ppResponse != null) { TransactionResponse txnResponse = ppResponse.TransactionResponse; if (txnResponse != null) { if (txnResponse.Result == 0) // Success { RecurringResponse recurringResponse = ppResponse.RecurringResponse; if (recurringResponse != null) { var scheduledTransaction = new FinancialScheduledTransaction(); scheduledTransaction.TransactionCode = recurringResponse.TrxPNRef; scheduledTransaction.GatewayScheduleId = recurringResponse.ProfileId; scheduledTransaction.FinancialGatewayId = financialGateway.Id; GetScheduledPaymentStatus(scheduledTransaction, out errorMessage); return(scheduledTransaction); } else { errorMessage = "Invalid recurring response from the financial gateway"; } } else { errorMessage = string.Format("[{0}] {1}", txnResponse.Result, txnResponse.RespMsg); } } else { errorMessage = "Invalid transaction response from the financial gateway"; } } else { errorMessage = "Invalid response from the financial gateway."; } return(null); }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DORecurringPayment.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(); RecurringInfo RecurInfo = new RecurringInfo(); RecurInfo.OrigProfileId = "<PROFILE_ID>"; // RT0000001350 RecurInfo.PaymentNum = "2"; // The failed payment to be retried. // 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"; Inv.BillTo = Bill; /////////////////////////////////////////////////////////////////// // Create a new Recurring Payment Transaction. RecurringPaymentTransaction Trans = new RecurringPaymentTransaction( User, Connection, RecurInfo, Inv, PayflowUtility.RequestId); // 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("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { Console.WriteLine("RPREF = " + RecurResponse.RPRef); Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); } // 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: DORecurringModify.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(); RecurringInfo RecurInfo = new RecurringInfo(); RecurInfo.OrigProfileId = "<PROFILE_ID>"; // RT0000001350 RecurInfo.ProfileName = "<PROFILE_NAME>"; // Test_Profile // Create a new Invoice data object with the Amount, Billing Address etc. details for the data you // want to change. 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.BillToEmail = "*****@*****.**"; Bill.BillToPhone = "123-123-1234"; Inv.BillTo = Bill; // If you want to modify the credit card information, create a new Payment Device - Credit Card data object. // The input parameters are Credit Card Number and Expiration Date of the Credit Card. CreditCard CC = new CreditCard("5105105105105100", "0115"); // Create a new Tender - Card Tender data object. CardTender Card = new CardTender(CC); // If NO card details available and want to modify only information like E-Mail or Phone Number, use following: //RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, Inv, null, PayflowUtility.RequestId); // If you want to modify the RecurringInfo information only, use the following: //RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, PayflowUtility.RequestId); // Create a new Recurring Modify Transaction. RecurringModifyTransaction Trans = new RecurringModifyTransaction(User, Connection, RecurInfo, Inv, Card, PayflowUtility.RequestId); // 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("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { Console.WriteLine("RPREF = " + RecurResponse.RPRef); Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); } // 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(); }
/// <summary> /// Gets <see cref="FinancialScheduledTransactionStatus" /> mapped from <seealso cref="SubscriptionStatus"/> /// </summary> /// <returns></returns> private Rock.Model.FinancialScheduledTransactionStatus?GetFinancialScheduledTransactionStatus(RecurringResponse recurringResponse) { var subscriptionStatus = recurringResponse?.Status; switch (subscriptionStatus.ToLower()) { // The PayflowPro documentation doesn't say what the possible status values are. But 'active' is a known value that comes back. case "active": return(Model.FinancialScheduledTransactionStatus.Active); default: // this will probably return null, but just in case they have a status named // the same as one of FinancialScheduledTransactionStatus status, this will return the one that matches return(subscriptionStatus?.ConvertToEnumOrNull <FinancialScheduledTransactionStatus>()); } }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DORecurring.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 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"; Inv.BillTo = Bill; // Create a new Payment Device - Credit Card data object. // The input parameters are Credit Card Number and Expiration Date of the Credit Card. CreditCard CC = new CreditCard("5105105105105100", "0125"); CC.Cvv2 = "123"; // Create a new Tender - Card Tender data object. CardTender Card = new CardTender(CC); RecurringInfo RecurInfo = new RecurringInfo(); // The date that the first payment will be processed. // This will be of the format mmddyyyy. RecurInfo.Start = "<MMDDYYYY>"; RecurInfo.ProfileName = "<TestProfileName>"; // Specifies how often the payment occurs. All PAYPERIOD values must use // capital letters and can be any of DAY / WEEK / BIWK / SMMO / FRWK / ] // MONT / QTER / SMYR / YEAR RecurInfo.PayPeriod = "MONT"; // Create a new Recurring Transaction. RecurringTransaction Trans = new RecurringTransaction("A", RecurInfo, User, Connection, Inv, Card, PayflowUtility.RequestId); // Submit the Transaction Response Resp = Trans.SubmitTransaction(); if (Resp != null) { // Get the Transaction Response parameters. TransactionResponse TrxnResponse = Resp.TransactionResponse; if (TrxnResponse != null) { Console.WriteLine("RESULT = " + TrxnResponse.Result); Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { Console.WriteLine("RPREF = " + RecurResponse.RPRef); Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); } } // 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(Environment.NewLine + "Press Enter to Continue ..."); Console.ReadLine(); }
public override AuthorizeRecurringTransactionResponse DoAuthorizeRecurring(AuthorizeRecurringTransactionRequest authorizeRequest) { VerifyStatus(); Payment payment = authorizeRequest.Payment; if (payment == null) { throw new ArgumentNullException("request.Payment"); } Order order = payment.Order; if (order == null) { throw new ArgumentNullException("request.Payment.Order"); } User user = order.User; if (user == null) { throw new ArgumentNullException("request.Payment.Order.User"); } AuthorizeRecurringTransactionResponse response = new AuthorizeRecurringTransactionResponse(); AuthorizeTransactionRequest authRequest; Transaction tr1, tr2, errTrans; //VALIDATE THE PAYMENT PERIOD int payPeriod = GetPayPeriod(authorizeRequest); if (payPeriod == int.MinValue) { errTrans = Transaction.CreateErrorTransaction(this.PaymentGatewayId, authorizeRequest, "E", "The specified payment interval is not valid for this processor."); return(new AuthorizeRecurringTransactionResponse(errTrans)); } if (authorizeRequest.RecurringChargeSpecified) { //make a sale transaction first authRequest = new AuthorizeTransactionRequest(authorizeRequest.Payment, authorizeRequest.RemoteIP); authRequest.Capture = true; authRequest.Amount = authorizeRequest.Amount; tr1 = DoAuthorize(authRequest); if (tr1.TransactionStatus != TransactionStatus.Successful) { errTrans = Transaction.CreateErrorTransaction(PaymentGatewayId, authorizeRequest, "E", "Authorization Failed."); errTrans.TransactionType = TransactionType.AuthorizeRecurring; response.AddTransaction(tr1); response.AddTransaction(errTrans); response.Status = TransactionStatus.Failed; return(response); } response.AddTransaction(tr1); } RecurringRequest request = InitializeAuthRecurringRequest(authorizeRequest, payPeriod); RecurringResponse recResponse = null; //RECORD REQUEST : TODO /*if (this.UseDebugMode) * { * string reqDebug = BuildRequestDebug(request); * this.RecordCommunication(this.Name, CommunicationDirection.Send, reqDebug); * }*/ //TODO : Test mode is not supported. if (this.UseTestMode) { recResponse = (RecurringResponse)TransactionClient.doTransaction(request, this.AccountToken); } else { recResponse = (RecurringResponse)TransactionClient.doTransaction(request, this.AccountToken); } if (recResponse != null) { //RECORD RESPONSE if (this.UseDebugMode) { string respDebug = BuildRecurringResponseDebug(recResponse); this.RecordCommunication(this.Name, CommunicationDirection.Receive, respDebug, null); } tr2 = ProcessRecurringResponse(authorizeRequest, recResponse); response.AddTransaction(tr2); response.Status = tr2.TransactionStatus; return(response); } else { throw new Exception("Operation Failed, Response is null."); } }
private Transaction ProcessRecurringResponse(AuthorizeRecurringTransactionRequest authRequest, RecurringResponse response) { //CREATE THE TRANSACTION OBJECT Transaction transaction = new Transaction(); transaction.PaymentGatewayId = this.PaymentGatewayId; transaction.TransactionType = TransactionType.AuthorizeRecurring; LSDecimal transAmount = authRequest.RecurringChargeSpecified ? authRequest.RecurringCharge : authRequest.Amount; transaction.Amount = transAmount; if (response.getResponseCode() != 1) { transaction.TransactionStatus = TransactionStatus.Failed; transaction.ResponseCode = response.getResponseCode().ToString(); transaction.ResponseMessage = response.getResponseCodeText(); } else { transaction.TransactionStatus = TransactionStatus.Successful; //transaction.ProviderTransactionId = response.getReferenceId(); transaction.TransactionDate = response.getTimeStamp(); transaction.ResponseCode = response.getResponseCode().ToString(); transaction.ResponseMessage = response.getResponseCodeText(); HttpContext context = HttpContext.Current; if (context != null) { transaction.RemoteIP = context.Request.ServerVariables["REMOTE_ADDR"]; transaction.Referrer = context.Request.ServerVariables["HTTP_REFERER"]; } } return(transaction); }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DORecurringAdd.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(); // Creating a profile where our customer is paying three installments of $25.75 with a shipping // charge of $9.95. So, our first payment will be $25.75 + 9.95 with two more payments of $25.75 due. // // This is just one example of how you might create a new profile. // 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.75), "USD"); Inv.Amt = Amt; //Inv.PoNum = "PO12345"; Inv.InvNum = "INV12345"; // Set the Billing Address details. // Only Street and Zip are set below for AVS check; however, you would probably want // to include full name and address information. BillTo Bill = new BillTo(); Bill.BillToStreet = "123 Main St."; Bill.BillToZip = "12345"; Bill.BillToCountry = "US"; Inv.BillTo = Bill; // Create a new Payment Device - Credit Card data object. // The input parameters are Credit Card Number and Expiration Date of the Credit Card. CreditCard CC = new CreditCard("5105105105105100", "0115"); // CVV2 is used for Optional Transaction (Sale or Authorization) Only. It is not stored as // part of the profile, nor is it sent when payments are made. CC.Cvv2 = "123"; // Create a new Tender - Card Tender data object. CardTender Card = new CardTender(CC); RecurringInfo RecurInfo = new RecurringInfo(); // The date that the first payment will be processed. // This will be of the format mmddyyyy. RecurInfo.Start = "07152008"; RecurInfo.ProfileName = "Test_Profile"; // User provided Profile Name. // Specifies how often the payment occurs. All PAYPERIOD values must use // capital letters and can be any of WEEK / BIWK / SMMO / FRWK / MONT / // QTER / SMYR / YEAR RecurInfo.PayPeriod = "WEEK"; RecurInfo.Term = 2; // Number of payments // Peform an Optional Transaction. RecurInfo.OptionalTrx = "S"; // S = Sale, A = Authorization // Set the amount if doing a "Sale" for the Optional Transaction. Currency oTrxAmt = new Currency(new decimal(25.75 + 9.95), "USD"); RecurInfo.OptionalTrxAmt = oTrxAmt; // Create a new Recurring Add Transaction. RecurringAddTransaction Trans = new RecurringAddTransaction( User, Connection, Inv, Card, RecurInfo, PayflowUtility.RequestId); // Use ORIGID to create a profile based on the details of another transaction. See Reference Transaction. //Trans.OrigId = "<ORIGINAL_PNREF>"; // 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("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { String ProfileMsg; if (TrxnResponse.Result == 0) { ProfileMsg = "Profile Created."; } else { ProfileMsg = "Error, Profile Not Created."; } Console.WriteLine("------------------------------------------------------"); Console.WriteLine(("Profile Status: " + ProfileMsg)); Console.WriteLine("Recurring Profile Reference (RPREF) = " + RecurResponse.RPRef); Console.WriteLine("Recurring Profile ID (PROFILEID) = " + RecurResponse.ProfileId); // Was an Optional Transaction processed? if (RecurResponse.TrxResult != null) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Optional Transaction Details:"); Console.WriteLine("Transaction PNREF (TRXPNREF) = " + RecurResponse.TrxPNRef); Console.WriteLine("Transaction Result (TRXRESULT) = " + RecurResponse.TrxResult); Console.WriteLine("Transaction Message (TRXRESPMSG) = " + RecurResponse.TrxRespMsg); Console.WriteLine(("Authorization (AUTHCODE) = " + TrxnResponse.AuthCode)); Console.WriteLine(("Security Code Match (CVV2MATCH) = " + TrxnResponse.CVV2Match)); Console.WriteLine(("Street Address Match (AVSADDR) = " + TrxnResponse.AVSAddr)); Console.WriteLine(("Streep Zip Match (AVSZIP) = " + TrxnResponse.AVSZip)); Console.WriteLine(("International Card (IAVS) = " + TrxnResponse.IAVS)); // Was this a duplicate transaction? // If this value is true, you will probably receive a result code 19, Original transaction ID not found. Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Duplicate Response:"); String DupMsg; if (TrxnResponse.Duplicate == "1") { DupMsg = "Duplicate Transaction"; } else { DupMsg = "Not a Duplicate Transaction"; } Console.WriteLine("Duplicate Transaction (DUPLICATE) = " + DupMsg); } } // 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: DORecurringInquiry.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(); RecurringInfo RecurInfo = new RecurringInfo(); RecurInfo.OrigProfileId = "<PROFILE_ID>"; // RT0000001350 // To show payment history instead of Profile details, change to "Y". // To view "Optional Transactions", use 'O'. RecurInfo.PaymentHistory = "N"; /////////////////////////////////////////////////////////////////// // Create a new Recurring Inquiry Transaction. RecurringInquiryTransaction Trans = new RecurringInquiryTransaction( User, Connection, RecurInfo, PayflowUtility.RequestId); // 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("RESPMSG = " + TrxnResponse.RespMsg); } // Get the Recurring Response parameters. RecurringResponse RecurResponse = Resp.RecurringResponse; if (RecurResponse != null) { Console.WriteLine("RPREF = " + RecurResponse.RPRef); Console.WriteLine("PROFILEID = " + RecurResponse.ProfileId); // Show Profile Details. if (RecurResponse.InquiryParams.Count == 0) { Console.WriteLine("STATUS = " + RecurResponse.Status); Console.WriteLine("PROFILENAME = " + RecurResponse.ProfileName); Console.WriteLine("START = " + RecurResponse.Start); Console.WriteLine("TERM = " + RecurResponse.Term); Console.WriteLine("PAYMENTSLEFT = " + RecurResponse.PaymentsLeft); Console.WriteLine("NEXTPAYMENT = " + RecurResponse.NextPayment); Console.WriteLine("PAYPERIOD = " + RecurResponse.PayPeriod); Console.WriteLine("TENDER = " + RecurResponse.Tender); Console.WriteLine("AMT = " + RecurResponse.Amt); Console.WriteLine("ACCT = " + RecurResponse.Acct); Console.WriteLine("EXPDATE = " + RecurResponse.ExpDate); Console.WriteLine("AGGREGATEAMT = " + RecurResponse.AggregateAmt); Console.WriteLine("AGGREGATEOPTIONALAMT = " + RecurResponse.AggregateOptionalAmt); Console.WriteLine("MAXFAILPAYMENTS = " + RecurResponse.MaxFailPayments); Console.WriteLine("NUMFAILPAYMENTS = " + RecurResponse.NumFailPayments); Console.WriteLine("RETRYNUMDAYS = " + RecurResponse.RetryNumDays); Console.WriteLine("END = " + RecurResponse.End); Console.WriteLine("FIRSTNAME = " + RecurResponse.Name); Console.WriteLine("LASTNAME = " + RecurResponse.LastName); Console.WriteLine("STREET = " + RecurResponse.Street); Console.WriteLine("ZIP = " + RecurResponse.Zip); } else { // Display the Payment History instead of Profile data. // Payment History is stored in the HASHTABLE RecurResponse.InquiryParams. // PAYMENTHISTORY = Y or O Console.WriteLine("INQUIRY PARAMS"); int x = 0; char Tab = (char)9; while (true) { x++; if (RecurResponse.InquiryParams["P_PNREF" + x.ToString()] == null) { break; } Console.WriteLine("PAYMENT: {0}" + Tab + "RESULT: {1}" + Tab + "PNREF: " + "{2}" + Tab + "AMOUNT: " + "{3}" + Tab + "TRANSTIME: " + "{4}" + Tab + "TRANSTATE: " + "{5}" + Tab + "TENDER: " + "{6}" + Tab, x, RecurResponse.InquiryParams["P_RESULT" + x.ToString()], RecurResponse.InquiryParams["P_PNREF" + x.ToString()], RecurResponse.InquiryParams["P_AMT" + x.ToString()], RecurResponse.InquiryParams["P_TRANSTIME" + x.ToString()], RecurResponse.InquiryParams["P_TRANSTATE" + x.ToString()], RecurResponse.InquiryParams["P_TENDER" + x.ToString()]); } } } 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(); }