/// <summary> /// This class is used to create and perform an Order Transaction for Express Checkout. /// /// An Order transaction represents an agreement to pay one or more authorized amounts up to /// the specified total over a maximum of 29 days. /// </summary> /// <example>This example shows how to create and perform a order transaction as part of Express Checkout. /// <code lang="C#" escaped="false"> /// .......... /// .......... /// //Populate required data objects. /// .......... /// .......... /// /// // Create the Tender object. /// PayPalTender Tender = new PayPalTender(SetRequest); /// /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// // authorized amounts up to the specified total over a maximum of 29 days. /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); /// /// //Submit the transaction. /// Trans.SubmitTransaction(); /// /// // Get the Response. /// Response Resp = Trans.Response; /// if (Resp != null) /// { /// // Get the Transaction Response parameters. /// TransactionResponse TrxnResponse = Resp.TransactionResponse; /// if (TrxnResponse != null) /// { /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); /// } /// // Get the Fraud Response parameters. /// FraudResponse FraudResp = Resp.FraudResponse; /// if (FraudResp != null) /// { /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); /// } /// } /// // Get the Context and check for any contained SDK specific errors. /// Context Ctx = Resp.TransactionContext; /// if (Ctx != null && Ctx.getErrorCount() > 0) /// { /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); /// } ///</code> ///<code lang="Visual Basic" escaped="false"> /// .......... /// .......... /// 'Populate required data objects. /// .......... /// .......... /// ' Create the Tender object. /// Dim Tender As New PayPalTender(SetRequest) /// /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// ' authorized amounts up to the specified total over a maximum of 29 days. /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) /// /// ' Submit the transaction. /// Trans.SubmitTransaction() /// /// ' Get the Response. /// Dim Resp As Response = Trans.Response /// /// If Not Resp Is Nothing Then /// ' Get the Transaction Response parameters. /// /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse /// /// If Not TrxnResponse Is Nothing Then /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) /// End If /// End If /// /// ' Get the Context and check for any contained SDK specific errors. /// Dim Ctx As Context = Resp.TransactionContext /// /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) /// End If /// </code> /// </example> /// <param name="UserInfo">User Info object populated with user credentials.</param> /// <param name="Invoice">Invoice object.</param> /// <param name="Tender">Tender object </param> /// <param name="RequestId">Request Id</param> public OrderTransaction(UserInfo UserInfo, Invoice Invoice, PayPalTender Tender, String RequestId) : base("0", UserInfo, Invoice, Tender, RequestId) { }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DOUpdateEC.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(); // You can use the Update Billing Agreement request to cancel the billing agreement or update // the billing agreement description. // // For more information on Reference Transactions, see the DOSetEC Sample for more details. // For Express Checkout Reference Transaction without Purchase. ECUpdateBARequest UpdateRequest = new ECUpdateBARequest("<BAID>", "<BA_STATUS>", "<BA_DESC>"); // Create the Tender object. PayPalTender Tender = new PayPalTender(UpdateRequest); // Create the transaction object. We do not pass a Transaction Type for an update call. BaseTransaction Trans = new BaseTransaction( null, User, Connection, null, Tender, 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) { // PNREF is not returned with an Update call. Console.WriteLine("RESULT = " + TrxnResponse.Result); Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); if (TrxnResponse.Result == 0) { Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); Console.WriteLine("PAYERSTATUS = " + Trans.Response.ExpressCheckoutGetResponse.PayerStatus); Console.WriteLine("FIRST = " + Trans.Response.ExpressCheckoutGetResponse.FirstName); Console.WriteLine("LAST = " + Trans.Response.ExpressCheckoutGetResponse.LastName); Console.WriteLine("EMAIL = " + Trans.Response.ExpressCheckoutGetResponse.EMail); Console.WriteLine("BAID = " + Trans.Response.ExpressCheckoutDoResponse.BAId); Console.WriteLine("BA_STATUS = " + Trans.Response.ExpressCheckoutUpdateResponse.BA_Status); Console.WriteLine("BA_DESC = " + Trans.Response.ExpressCheckoutUpdateResponse.BA_Desc); } } // If value is true, then the Request ID has not been changed and the original response // of the original transction is returned. Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); } // 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> /// /// </summary> /// <param name="Tender"></param> /// <param name="Invoice"></param> /// <param name="UserInfo"></param> /// <param name="RequestId"></param> public BasicAuthorizationTransaction(PayPalTender Tender, Invoice Invoice, UserInfo UserInfo, String RequestId) : base("B", UserInfo, Invoice, Tender, RequestId) { }
/// <summary> /// This class is used to create and perform an Order Transaction for Express Checkout. /// /// An Order transaction represents an agreement to pay one or more authorized amounts up to /// the specified total over a maximum of 29 days. /// </summary> /// <example>This example shows how to create and perform a order transaction as part of Express Checkout. /// <code lang="C#" escaped="false"> /// .......... /// .......... /// //Populate required data objects. /// .......... /// .......... /// /// // Create the Tender object. /// PayPalTender Tender = new PayPalTender(SetRequest); /// /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// // authorized amounts up to the specified total over a maximum of 29 days. /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); /// /// //Submit the transaction. /// Trans.SubmitTransaction(); /// /// // Get the Response. /// Response Resp = Trans.Response; /// if (Resp != null) /// { /// // Get the Transaction Response parameters. /// TransactionResponse TrxnResponse = Resp.TransactionResponse; /// if (TrxnResponse != null) /// { /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); /// } /// // Get the Fraud Response parameters. /// FraudResponse FraudResp = Resp.FraudResponse; /// if (FraudResp != null) /// { /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); /// } /// } /// // Get the Context and check for any contained SDK specific errors. /// Context Ctx = Resp.TransactionContext; /// if (Ctx != null && Ctx.getErrorCount() > 0) /// { /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); /// } ///</code> ///<code lang="Visual Basic" escaped="false"> /// .......... /// .......... /// 'Populate required data objects. /// .......... /// .......... /// ' Create the Tender object. /// Dim Tender As New PayPalTender(SetRequest) /// /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// ' authorized amounts up to the specified total over a maximum of 29 days. /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) /// /// ' Submit the transaction. /// Trans.SubmitTransaction() /// /// ' Get the Response. /// Dim Resp As Response = Trans.Response /// /// If Not Resp Is Nothing Then /// ' Get the Transaction Response parameters. /// /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse /// /// If Not TrxnResponse Is Nothing Then /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) /// End If /// End If /// /// ' Get the Context and check for any contained SDK specific errors. /// Dim Ctx As Context = Resp.TransactionContext /// /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) /// End If /// </code> /// </example> /// <param name="UserInfo">User Info object populated with user credentials.</param> /// <param name="PayflowConnectionData">Connection credentials object.</param> /// <param name="Invoice">Invoice object.</param> /// <param name="Tender">Tender object </param> /// <param name="RequestId">Request Id</param> public OrderTransaction(UserInfo UserInfo, PayflowConnectionData PayflowConnectionData, Invoice Invoice, PayPalTender Tender, String RequestId) : base("O", UserInfo, PayflowConnectionData, Invoice, Tender, RequestId) { }
/// <summary> /// </summary> /// <param name="tender"></param> /// <param name="invoice"></param> /// <param name="userInfo"></param> /// <param name="requestId"></param> public BasicAuthorizationTransaction(PayPalTender tender, Invoice invoice, UserInfo userInfo, string requestId) : base("B", userInfo, invoice, tender, requestId) { }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DOSetEC.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. // See the DoSaleComplete sample for more information on setting the Connection object. PayflowConnectionData Connection = new PayflowConnectionData(); // Create the invoice object and set the amount value. Invoice Inv = new Invoice(); Inv.Amt = new Currency(new decimal(21.98), "USD"); Inv.OrderDesc = "This is my Order Description"; // **** PayPal Pay Later Service **** // PayPal Pay Later is a new, convenient, and secure service that allows you to offer your // customers promotional financing. Buyers that choose the promotional offer can defer // payments for purchases on participating merchant web sites, allowing them to shop now and // pay later. // The PayPal Pay Later service allows online merchants to offer promotional financing to // buyers at checkout - even if a buyer doesn't have a PayPal account. Promotional offers, such as // no payments for 90 days, give merchants new and powerful ways to market to online // shoppers. // The PayPal Pay Later service is issued by GE Money Bank, one of the world's leading // providers of consumer credit. // **** Signing Up for PayPal Pay Later **** // PayPal's new promotional financing is currently available to consumers and select merchants // in the U.S. If you are a merchant and would like to add this service, please contact your sales // representative for information and additional documentation. // //PayLater setPayLater = new PayLater(); //setPayLater.ShippingMethod = "UPSGround"; //setPayLater.ProductCategory = "E"; // Camera and Photos //setPayLater.PayPalCheckoutBtnType = "P"; // You can combine up to 10 promotions for PayPal Promotional Financing. // L_PROMOCODE0 //PayLaterLineItem setPayLaterLineItem = new PayLaterLineItem(); //setPayLaterLineItem.PromoCode = "101"; //setPayLater.PayLaterAddLineItem(setPayLaterLineItem); // L_PROMOCODE1 //PayLaterLineItem setPayLaterLineItem1 = new PayLaterLineItem(); //setPayLaterLineItem1.PromoCode = "102"; //setPayLater.PayLaterAddLineItem(setPayLaterLineItem1); // **** Performing a Standard Transaction using Express Checkout **** // // Express Checkout offers your customers an easy, convenient checkout experience. It lets them // use shipping and billing information stored securely at PayPal to check out, so they don’t have // to re-enter it on your site. // // From the perspective of website development, Express Checkout works like other Payflow Pro // features. You submit transaction information to the server as name-value pair parameter // strings. // // Create the data object for Express Checkout SET operation using ECSetRequest Data Object. ECSetRequest SetRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com"); // If using Pay Later, you would create the data object as below. //ECSetRequest setRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", setPayLater); // **** Performing a Reference Transaction using Express Checkout **** // // NOTE: You must be enabled by PayPal to use reference transactions. Contact your account manager // or the sales department for more details. // // See the "Using Reference Transactions with Express Checkout" guide that is supplied to you // once your account is active with the feature. // *** With Making a Purchase *** // Say that you have implemented Express Checkout on your website. The customer logs in to // purchase an item of merchandise and chooses PayPal to pay for it. In the normal Express // Checkout flow, the customer is then redirected to PayPal to log in to verify their billing // information. If the customer approves payment on the Confirmation page when you are using // a reference transaction, you receive the billing agreement as part of the transaction.You can // use that billing agreement later to bill the customer a set amount on a recurring basis, such as // once-a-month, for future purchases. The customer doesn’t need to log into PayPal each time to // make a payment. // // Create the data object for Express Checkout Reference Transaction SET operation // with Purchase using ECSetRequest Data Object. //ECSetRequest SetRequest = new ECSetRequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", // "MerchantInitiatedBilling", "Test Description", "any", "BACustom"); // *** Without Making a Purchase *** // Typically, the customer chooses a billing agreement without making a purchase when they // subscribe for merchandise they will pay for on a recurring schedule. If, for example, the // customer logs in to your website to order a magazine subscription, you set up an agreement to // bill the customer on a scheduled basis, say, once a month. In the billing agreement flow // without purchase, the customer is redirected to PayPal to log in. On the PayPal site, they // consent to the billing agreement. Next month, when you send the customer the first magazine // issue, the billing agreement authorizes you to start charging the customer’s PayPal account on // the agreed upon recurring basis without having the customer log in to PayPal. // // Create the data object for Express Checkout Reference Transaction SET operation // without Purchase using ECSetBARequest Data Object. //ECSetBARequest SetRequest = new ECSetBARequest("http://www.myreturnurl.com", "http://www.mycancelurl.com", // "MerchantInitiatedBilling", "Test Description", "any", "BACustom"); // Create the Tender object. PayPalTender Tender = new PayPalTender(SetRequest); // Create the transaction object. AuthorizationTransaction Trans = new AuthorizationTransaction (User, Connection, Inv, Tender, PayflowUtility.RequestId); // Create an Order Transaction. An Order transaction represents an agreement to pay one or more // authorized amounts up to the specified total over a maximum of 29 days. // Refer to the Express Checkout for Payflow Pro Developer's Guide regarding Orders. //OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, 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.ToString()); Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); // 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); } if (TrxnResponse.Result == 0) { Console.WriteLine(Environment.NewLine + "Transaction was Approved."); Console.WriteLine(Environment.NewLine + "The next step would be to redirect to PayPal to allow customer to log"); Console.WriteLine("into their account to select payment. For this demo, DO NOT CLOSE the browser"); Console.WriteLine("as you will need the TOKEN and/or PAYER ID from the URL for the GET and DO"); Console.WriteLine("samples."); Console.WriteLine(Environment.NewLine + "Make sure you are logged into Developer Central (https://developer.paypal.com) before continuing."); Console.WriteLine(Environment.NewLine + "Press <Enter> to redirect to PayPal."); Console.ReadLine(); // Using the PayPal SandBox for Express Checkout: // Before you can use the PayPal Sandbox with a Gateway account you'll need to do the following: // To setup a PayPal Sandbox account to work with a Payflow Pro account you will need to go to // https://developer.paypal.com and create an account. Once you have access to the Sandbox then // you will be able to set up test business accounts, premier accounts and personal accounts. Please // set up a test business account and personal account so you can test Express Checkout. // // Once you have a test business account created, create a ticket at http://www.paypal.com/mts // under Contact Support and request to have your Payflow Pro (US, AU) or Websites Payments Pro // Payflow Edition (UK) account modified to use the PayPal Sandbox. Provide the e-mail ID you // used when you created your account on the Sandbox. // // Once you are notified that your account has been updated you will then need to modify the host // URLs of the Payflow Pro Express Checkout test servers to the URLs used by the Sandbox. // For example, https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<token>. // If the SET operation succeeds, you will get a secure session token id in the response of this // operation. Using this token, redirect the user's browser as follows: // For Regular Express Checkout or Express Checkout (Reference) with Purchase. String PayPalUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; // For Express Checkout (Reference) without Purchase. //String PayPalUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token="; PayPalUrl += Trans.Response.ExpressCheckoutSetResponse.Token; //Process.Start(PayPalUrl); // Open default browser. //Process.Start("iexplore.exe", PayPalUrl); Process.Start("C:\\Program Files\\Mozilla Firefox\\firefox.exe", PayPalUrl); } // 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> /// </summary> /// <param name="tender"></param> /// <param name="invoice"></param> /// <param name="userInfo"></param> /// <param name="payflowConnectionData"></param> /// <param name="requestId"></param> public BasicAuthorizationTransaction(PayPalTender tender, Invoice invoice, UserInfo userInfo, PayflowConnectionData payflowConnectionData, string requestId) : base("B", userInfo, payflowConnectionData, invoice, tender, requestId) { }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DOGetEC.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. PayflowConnectionData Connection = new PayflowConnectionData(); // Calling a GET operation is second step in PayPal Express checkout process. Once the // customner has logged into his/her paypal account, selected shipping address and clicked on // "Continue checkout", the PayPal server will redirect the page to the ReturnUrl you have // specified in the previous SET request. To obtain the shipping details chosen by the // Customer, you will then need to do a GET operation. // // For more information on Reference Transactions, see the DOSetEC Sample for more details. // For Regular Express Checkout or Express Checkout Reference Transaction with Purchase. ECGetRequest GetRequest = new ECGetRequest("<TOKEN>"); // For Express Checkout Reference Transaction without Purchase. //ECGetBARequest GetRequest = new ECGetBARequest("<TOKEN>"); // Create the Tender. PayPalTender Tender = new PayPalTender(GetRequest); // Create a transaction. AuthorizationTransaction Trans = new AuthorizationTransaction (User, Connection, null, Tender, 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.ToString()); Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); // The TOKEN is needed for the DODoEC Sample. Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); Console.WriteLine("EMAIL = " + Trans.Response.ExpressCheckoutGetResponse.EMail); // The PAYERID is needed for the DODoEC Sample. Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); Console.WriteLine("PAYERSTATUS = " + Trans.Response.ExpressCheckoutGetResponse.PayerStatus); // Express Checkout Transactions and Express Checkout Reference Transactions with Purchase // begin with EC, while Express Checkout Reference Transactions without Purchase begin with BA. // Reference Transactions without Purchase do not return shipping information. if (Trans.Response.ExpressCheckoutSetResponse.Token != null) { if (Trans.Response.ExpressCheckoutSetResponse.Token.StartsWith("EC")) { Console.WriteLine(Environment.NewLine + "Shipping Information:"); Console.WriteLine("FIRST = " + Trans.Response.ExpressCheckoutGetResponse.FirstName); Console.WriteLine("LAST = " + Trans.Response.ExpressCheckoutGetResponse.LastName); Console.WriteLine("SHIPTOSREET = " + Trans.Response.ExpressCheckoutGetResponse.ShipToStreet); Console.WriteLine("SHIPTOSTREET2 = " + Trans.Response.ExpressCheckoutGetResponse.ShipToStreet2); Console.WriteLine("SHIPTOCITY = " + Trans.Response.ExpressCheckoutGetResponse.ShipToCity); Console.WriteLine("SHIPTOSTATE = " + Trans.Response.ExpressCheckoutGetResponse.ShipToState); Console.WriteLine("SHIPTOZIP = " + Trans.Response.ExpressCheckoutGetResponse.ShipToZip); Console.WriteLine("SHIPTOCOUNTRY = " + Trans.Response.ExpressCheckoutGetResponse.ShipToCountry); Console.WriteLine("AVSADDR = " + Trans.Response.TransactionResponse.AVSAddr); } // BA_Flag is returned with Express Checkout Reference Transaction with Purchase. // See the notes in DOSetEC regarding this feature. if (Trans.Response.ExpressCheckoutGetResponse.BA_Flag != null) { Console.WriteLine(Environment.NewLine + "BA_FLAG = " + Trans.Response.ExpressCheckoutGetResponse.BA_Flag); if (Trans.Response.ExpressCheckoutGetResponse.BA_Flag == "1") { Console.WriteLine("Buyer Agreement was created."); } else { Console.WriteLine("Buyer Agreement not was accepted."); } } } // If value is true, then the Request ID has not been changed and the original response // of the original transction is returned. Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); } // 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: DODoEC.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(); // Once the customer has reviewed the shipping details and decides to continue // checkout by clicking on "Continue Checkout" button, it's time to actually // authorize the transaction. // This is the third step in PayPal Express Checkout, in which you need to perform a // DO operation to authorize the purchase amount. // // For more information on Reference Transactions, see the DOSetEC Sample for more details. // For Regular Express Checkout or Express Checkout Reference Transaction with Purchase. ECDoRequest DoRequest = new ECDoRequest("<TOKEN>", "<PAYERID>"); // For Express Checkout Reference Transaction without Purchase. //ECDoBARequest DoRequest = new ECDoBARequest("<TOKEN>", "<PAYERID>"); // Performing a Reference Transaction, Credit Transaction, Do Authorization or a Reauthorization // These transactions do not require a token or payerid. Additional fields // are set using the ExtendData, ECDoRequest or AuthorizationTransaction objects, see below. //ECDoRequest DoRequest = new ECDoRequest("", ""); // Perform a Do Reauthorization // To reauthorize an Authorization for an additional three-day honor period, you can use a Do // Reauthorization transaction. A Do Reauthorization can be used at most once during the 29-day // authorization period. // To set up a Do Reauthorization, you must pass ORIGID in the AuthorizationTransaction object // and set DoReauthorization to 1. //DoRequest.DoReauthorization("1"); // Populate Invoice object. Invoice Inv = new Invoice(); Inv.Amt = new Currency(new decimal(21.98), "USD"); Inv.Comment1 = "Testing Express Checkout"; // **** PayPal Pay Later Service **** // See DoSetEC.vb for information on PayPal's Pay Later Service. // Create the Tender object. PayPalTender Tender = new PayPalTender(DoRequest); // Create the transaction object. AuthorizationTransaction Trans = new AuthorizationTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); // Doing a credit? //CreditTransaction Trans = new CreditTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); // Using a Reference Transaction // To be able to "charge" a customer using their Billing Agreement you will need to pass the BAID // and other parameters via the ExtendData Object. //ExtendData BAId = new ExtendData("BAID", "<BAID>"); //Trans.AddToExtendData(BAId); //ExtendData CaptureComplete = new ExtendData("CAPTURECOMPLETE", "NO"); //Trans.AddToExtendData(CaptureComplete); //ExtendData MaxAmt = new ExtendData("MAXAMT", "15.00"); //Trans.AddToExtendData(MaxAmt); // Perform a Do Authorization or Do Reauthorization // You must pass ORIGID using the PNREF of the original order transaction. //Trans.OrigId("<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); Console.WriteLine("PNREF = " + TrxnResponse.Pnref); Console.WriteLine("PPREF = " + TrxnResponse.PPref); Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); Console.WriteLine("PAYERID = " + Trans.Response.ExpressCheckoutGetResponse.PayerId); Console.WriteLine("PAYMENTTYPE = " + Trans.Response.TransactionResponse.PaymentType); Console.WriteLine("PENDINGREASON = " + Trans.Response.TransactionResponse.PendingReason); // BAID is returned with Express Checkout Reference Transaction with and without Purchase. // See the notes in DOSetEC regarding this feature. if (Trans.Response.ExpressCheckoutDoResponse.BAId != null) { Console.WriteLine(Environment.NewLine + "BAID = " + Trans.Response.ExpressCheckoutDoResponse.BAId); } // If value is true, then the Request ID has not been changed and the original response // of the original transction is returned. Console.WriteLine(Environment.NewLine + "DUPLICATE = " + TrxnResponse.Duplicate); } // 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> /// This class is used to create and perform an Order Transaction for Express Checkout. /// An Order transaction represents an agreement to pay one or more authorized amounts up to /// the specified total over a maximum of 29 days. /// </summary> /// <example> /// This example shows how to create and perform a order transaction as part of Express Checkout. /// <code lang="C#" escaped="false"> /// .......... /// .......... /// //Populate required data objects. /// .......... /// .......... /// /// // Create the Tender object. /// PayPalTender Tender = new PayPalTender(SetRequest); /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// // authorized amounts up to the specified total over a maximum of 29 days. /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); /// /// //Submit the transaction. /// Trans.SubmitTransaction(); /// /// // Get the Response. /// Response Resp = Trans.Response; /// if (Resp != null) /// { /// // Get the Transaction Response parameters. /// TransactionResponse TrxnResponse = Resp.TransactionResponse; /// if (TrxnResponse != null) /// { /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); /// } /// // Get the Fraud Response parameters. /// FraudResponse FraudResp = Resp.FraudResponse; /// if (FraudResp != null) /// { /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); /// } /// } /// // Get the Context and check for any contained SDK specific errors. /// Context Ctx = Resp.TransactionContext; /// if (Ctx != null && Ctx.getErrorCount() > 0) /// { /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); /// } /// </code> /// <code lang="Visual Basic" escaped="false"> /// .......... /// .......... /// 'Populate required data objects. /// .......... /// .......... /// ' Create the Tender object. /// Dim Tender As New PayPalTender(SetRequest) /// /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// ' authorized amounts up to the specified total over a maximum of 29 days. /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) /// /// ' Submit the transaction. /// Trans.SubmitTransaction() /// ' Get the Response. /// Dim Resp As Response = Trans.Response /// /// If Not Resp Is Nothing Then /// ' Get the Transaction Response parameters. /// /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse /// /// If Not TrxnResponse Is Nothing Then /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) /// End If /// End If /// ' Get the Context and check for any contained SDK specific errors. /// Dim Ctx As Context = Resp.TransactionContext /// /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) /// End If /// </code> /// </example> /// <param name="userInfo">User Info object populated with user credentials.</param> /// <param name="invoice">Invoice object.</param> /// <param name="tender">Tender object </param> /// <param name="requestId">Request Id</param> public OrderTransaction(UserInfo userInfo, Invoice invoice, PayPalTender tender, string requestId) : base("0", userInfo, invoice, tender, requestId) { }
/// <summary> /// This class is used to create and perform an Order Transaction for Express Checkout. /// An Order transaction represents an agreement to pay one or more authorized amounts up to /// the specified total over a maximum of 29 days. /// </summary> /// <example> /// This example shows how to create and perform a order transaction as part of Express Checkout. /// <code lang="C#" escaped="false"> /// .......... /// .......... /// //Populate required data objects. /// .......... /// .......... /// /// // Create the Tender object. /// PayPalTender Tender = new PayPalTender(SetRequest); /// // Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// // authorized amounts up to the specified total over a maximum of 29 days. /// OrderTransaction Trans = new OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId); /// /// //Submit the transaction. /// Trans.SubmitTransaction(); /// /// // Get the Response. /// Response Resp = Trans.Response; /// if (Resp != null) /// { /// // Get the Transaction Response parameters. /// TransactionResponse TrxnResponse = Resp.TransactionResponse; /// if (TrxnResponse != null) /// { /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString()); /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token); /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId); /// } /// // Get the Fraud Response parameters. /// FraudResponse FraudResp = Resp.FraudResponse; /// if (FraudResp != null) /// { /// Console.WriteLine("PREFPSMSG = " + FraudResp.PreFpsMsg); /// Console.WriteLine("POSTFPSMSG = " + FraudResp.PostFpsMsg); /// } /// } /// // Get the Context and check for any contained SDK specific errors. /// Context Ctx = Resp.TransactionContext; /// if (Ctx != null && Ctx.getErrorCount() > 0) /// { /// Console.WriteLine(Environment.NewLine + "Errors = " + Ctx.ToString()); /// } /// </code> /// <code lang="Visual Basic" escaped="false"> /// .......... /// .......... /// 'Populate required data objects. /// .......... /// .......... /// ' Create the Tender object. /// Dim Tender As New PayPalTender(SetRequest) /// /// ' Create an Order Transaction. An Order transaction represents an agreement to pay one or more /// ' authorized amounts up to the specified total over a maximum of 29 days. /// Dim Trans As New OrderTransaction(User, Connection, Inv, Tender, PayflowUtility.RequestId) /// /// ' Submit the transaction. /// Trans.SubmitTransaction() /// ' Get the Response. /// Dim Resp As Response = Trans.Response /// /// If Not Resp Is Nothing Then /// ' Get the Transaction Response parameters. /// /// Dim TrxnResponse As TransactionResponse = Resp.TransactionResponse /// /// If Not TrxnResponse Is Nothing Then /// Console.WriteLine("RESULT = " + TrxnResponse.Result.ToString) /// Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg) /// Console.WriteLine("TOKEN = " + Trans.Response.ExpressCheckoutSetResponse.Token) /// Console.WriteLine("CORRELATIONID = " + TrxnResponse.CorrelationId) /// End If /// End If /// ' Get the Context and check for any contained SDK specific errors. /// Dim Ctx As Context = Resp.TransactionContext /// /// If Not Ctx Is Nothing AndAlso Ctx.getErrorCount() > 0 Then /// Console.WriteLine(Constants.vbLf + "Errors = " + Ctx.ToString()) /// End If /// </code> /// </example> /// <param name="userInfo">User Info object populated with user credentials.</param> /// <param name="payflowConnectionData">Connection credentials object.</param> /// <param name="invoice">Invoice object.</param> /// <param name="tender">Tender object </param> /// <param name="requestId">Request Id</param> public OrderTransaction(UserInfo userInfo, PayflowConnectionData payflowConnectionData, Invoice invoice, PayPalTender tender, string requestId) : base("O", userInfo, payflowConnectionData, invoice, tender, requestId) { }