Invoice details about the merchant, payer, totals and terms.
Example #1
0
        /// <summary>
        /// API call example for UpdateInvoice
        /// </summary>
        /// <param name="context"></param>
        private void UpdateInvoice(HttpContext context)
        {
            // Collect input params
            String invoiceId = context.Request.Params["invoiceId"];
            String merchantEmail = context.Request.Params["merchantEmail"];
            String payerEmail = context.Request.Params["payerEmail"];
            PaymentTermsType paymentTerms = (PaymentTermsType) Enum.Parse(
                    typeof(PaymentTermsType), context.Request.Params["paymentTerms"]);
            String item_name1 = context.Request.Params["item_name1"];
            String item_quantity1 = context.Request.Params["item_quantity1"];
            String item_unitPrice1 = context.Request.Params["item_unitPrice1"];
            String item_name2 = context.Request.Params["item_name2"];
            String item_quantity2 = context.Request.Params["item_quantity2"];
            String item_unitPrice2 = context.Request.Params["item_unitPrice2"];
            String currencyCode = context.Request.Params["currencyCode"];

            InvoiceItemListType itemList = new InvoiceItemListType();
            itemList.item = new List<InvoiceItemType>();
            itemList.item.Add(new InvoiceItemType(
                        item_name1,
                        decimal.Parse(item_quantity1),
                        decimal.Parse(item_unitPrice1)));
            itemList.item.Add(new InvoiceItemType(
                        item_name2,
                        decimal.Parse(item_quantity2),
                        decimal.Parse(item_unitPrice2)));
            InvoiceType invoice = new InvoiceType(merchantEmail, payerEmail, itemList,
                currencyCode, paymentTerms);
            UpdateInvoiceRequest request = new UpdateInvoiceRequest(
                new RequestEnvelope(ERROR_LANGUAGE), invoiceId, invoice);

            // Create service object and make the API call
            InvoiceService service;
            UpdateInvoiceResponse response;

            try
            {
                service = getService(context);
                response = service.UpdateInvoice(request);
            }
            catch (Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();
            keyResponseParams.Add("API status", response.responseEnvelope.ack.ToString());
            keyResponseParams.Add("correlationId", response.responseEnvelope.correlationId);
            keyResponseParams.Add("invoiceId", response.invoiceID);
            keyResponseParams.Add("invoiceNumber", response.invoiceNumber);
            keyResponseParams.Add("invoiceUrl", response.invoiceURL);
            keyResponseParams.Add("totalAmount", response.totalAmount.ToString());
            displayResponse(context, "UpdateInvoice", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), response.error, null);
        }
Example #2
0
        public void Init()
        {
            errorResponse = new Dictionary<string, string>();

            errorResponse.Add("responseEnvelope.timestamp", "2011-05-11T22%3A05%3A33.962-07%3A00");
            errorResponse.Add("responseEnvelope.ack", "Failure");
            errorResponse.Add("responseEnvelope.correlationId", "b1985a21862fe");
            errorResponse.Add("responseEnvelope.build", "1877082");
            errorResponse.Add("error(0).errorId", "580022");
            errorResponse.Add("error(0).domain", "PLATFORM");
            errorResponse.Add("error(0).subdomain", "Application");
            errorResponse.Add("error(0).severity", "Error");
            errorResponse.Add("error(0).category", "Application");
            errorResponse.Add("error(0).message", "Invalid+request+parameter%3A+shippingTaxName+cannot+be+null");
            errorResponse.Add("error(0).parameter(0).name", "shippingTaxName");
            errorResponse.Add("error(0).parameter(1).name", "null");
            errorResponse.Add("error(1).errorId", "580022");
            errorResponse.Add("error(1).domain", "PLATFORM");
            errorResponse.Add("error(1).subdomain", "Application");
            errorResponse.Add("error(1).severity", "Error");
            errorResponse.Add("error(1).category", "Application");
            errorResponse.Add("error(1).message", "Invalid+request+parameter%3A+taxName+cannot+be+null");
            errorResponse.Add("error(1).parameter(0).name", "taxName");
            errorResponse.Add("error(1).parameter(1).name", "null");

            validCreateInvoiceResponse = new Dictionary<string, string>();
            validCreateInvoiceResponse.Add("responseEnvelope.timestamp", "2011-05-30T03:31:18.988-07:00");
            validCreateInvoiceResponse.Add("responseEnvelope.ack", "Success");
            validCreateInvoiceResponse.Add("responseEnvelope.correlationId", "9b3bb0a44d852");
            validCreateInvoiceResponse.Add("responseEnvelope.build", "1917403");
            validCreateInvoiceResponse.Add("invoiceID", "INV2-PCWG-P78G-7EYV-94QY");
            validCreateInvoiceResponse.Add("invoiceNumber", "0056");
            validCreateInvoiceResponse.Add("invoiceURL", "https://www.stage2sc5376.qa.paypal.com/us/cgi-bin/?cmd=_inv-details&id=INV2-PCWG-P78G-7EYV-94QY");

            validSendInvoiceResponse = new Dictionary<string, string>();
            validSendInvoiceResponse.Add("responseEnvelope.timestamp", "2011-05-30T03:31:18.988-07:00");
            validSendInvoiceResponse.Add("responseEnvelope.ack", "Success");
            validSendInvoiceResponse.Add("responseEnvelope.correlationId", "9b3bb0a44d852");
            validSendInvoiceResponse.Add("responseEnvelope.build", "1917403");
            validSendInvoiceResponse.Add("invoiceID", "INV2-PCWG-P78G-7EYV-94QY");
            validSendInvoiceResponse.Add("invoiceURL", "https://www.stage2sc5376.qa.paypal.com/us/cgi-bin/?cmd=_inv-details&id=INV2-PCWG-P78G-7EYV-94QY");

            this.addr = new BaseAddress();
            addr.city = "Austin";
            addr.countryCode = "US";
            addr.line1 = "1968 Ape Way";
            addr.line2 = "Apt 123";
            addr.postalCode = "78750";
            addr.state = "TX";

            bizInfo = new BusinessInfoType();
            bizInfo.firstName = "Bonzop";
            bizInfo.lastName = "Zaius";
            bizInfo.businessName = "Bonzop Inc";
            bizInfo.fax = "5126914161";
            bizInfo.phone = "5126914160";
            bizInfo.website = "www.bonzop-inc.com";
            bizInfo.customValue = "Business mumbo jumbo ©";

            invoice = new InvoiceType();
            invoice.billingInfo = this.bizInfo;
            invoice.currencyCode = "USD";
            invoice.discountAmount = 10.0M;
            invoice.discountPercent = 5;
            invoice.dueDate = "2011-11-04T00:00:00";
            invoice.invoiceDate = "2011-10-04T00:00:00";
            invoice.merchantEmail = "*****@*****.**";
            invoice.payerEmail = "*****@*****.**";
            invoice.merchantMemo = "memo";
            invoice.note = "Note about invoice";
            invoice.number = "FD-123-5421";
            invoice.paymentTerms = PaymentTermsType.NET4;
            invoice.shippingAmount = 2.1M;
            invoice.shippingTaxName = "Bonzop Inc";
            invoice.shippingTaxRate = 1.2M;
            invoice.terms = "Payment terms";
        }
        /// <summary>
        /// API call example for UpdateInvoice
        /// </summary>
        /// <param name="context"></param>
        private void UpdateInvoice(HttpContext context)
        {
            // Collect input params

            // (Required) ID of the invoice to update.
            string invoiceId = context.Request.Params["invoiceId"];

            // (Required) Merchant email address.
            string merchantEmail = context.Request.Params["merchantEmail"];

            // (Required) Payer email address.
            string payerEmail = context.Request.Params["payerEmail"];

            // (Required) Terms by which the invoice payment is due. It is one of the following values:
            // DueOnReceipt – Payment is due when the payer receives the invoice.
            // DueOnDateSpecified – Payment is due on the date specified in the invoice.
            // Net10 – Payment is due 10 days from the invoice date.
            // Net15 – Payment is due 15 days from the invoice date.
            // Net30 – Payment is due 30 days from the invoice date.
            // Net45 – Payment is due 45 days from the invoice date.
            InvoiceModelAlias.PaymentTermsType paymentTerms = (InvoiceModelAlias.PaymentTermsType)Enum.Parse(
                    typeof(InvoiceModelAlias.PaymentTermsType), context.Request.Params["paymentTerms"]);

            // (Required) SKU or name of the item. Character length and limitations: 30 characters maximum
            string item_name1 = context.Request.Params["item_name1"];

            // (Required) Item count. Valid values are 0 to 10.000.
            string item_quantity1 = context.Request.Params["item_quantity1"];

            // (Required) Price of the item, in the currency specified by the invoice.
            string item_unitPrice1 = context.Request.Params["item_unitPrice1"];

            // (Required) SKU or name of the item. Character length and limitations: 30 characters maximum
            string item_name2 = context.Request.Params["item_name2"];

            // (Required) Item count. Valid values are 0 to 10.000.
            string item_quantity2 = context.Request.Params["item_quantity2"];

            // (Required) Price of the item, in the currency specified by the invoice.
            string item_unitPrice2 = context.Request.Params["item_unitPrice2"];

            // (Required) Currency used for all invoice item amounts and totals.
            string currencyCode = context.Request.Params["currencyCode"];

            InvoiceModelAlias.InvoiceItemListType itemList = new InvoiceModelAlias.InvoiceItemListType();
            itemList.item = new List<InvoiceModelAlias.InvoiceItemType>();
            itemList.item.Add(new InvoiceModelAlias.InvoiceItemType(
                        item_name1,
                        Convert.ToDecimal(item_quantity1),
                        Convert.ToDecimal(item_unitPrice1)));
            itemList.item.Add(new InvoiceModelAlias.InvoiceItemType(
                        item_name2,
                        Convert.ToDecimal(item_quantity2),
                        Convert.ToDecimal(item_unitPrice2)));
            InvoiceModelAlias.InvoiceType invoice = new InvoiceModelAlias.InvoiceType(merchantEmail, payerEmail, itemList,
                currencyCode);
            invoice.paymentTerms = paymentTerms;
            InvoiceModelAlias.RequestEnvelope env = new InvoiceModelAlias.RequestEnvelope();

            // (Required) RFC 3066 language in which error messages are returned;
            // by default it is en_US, which is the only language currently supported.
            env.errorLanguage = ERROR_LANGUAGE;
            InvoiceModelAlias.UpdateInvoiceRequest request = new InvoiceModelAlias.UpdateInvoiceRequest(
               env, invoiceId, invoice);

            // Create service object and make the API call
            InvoiceAlias.InvoiceService service;
            InvoiceModelAlias.UpdateInvoiceResponse response;
            SignatureCredential cred = SetThirdPartyAuthorization(context);
            try
            {
                service = GetService(context);
                if (cred != null)
                {
                    response = service.UpdateInvoice(request, cred);
                }
                else
                {
                    response = service.UpdateInvoice(request);
                }
            }
            catch (Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();

            //Acknowledgement code. It is one of the following values:
            //Success – The operation completed successfully.
            //Failure – The operation failed.
            //SuccessWithWarning – The operation completed successfully; however, there is a warning message.
            //FailureWithWarning – The operation failed with a warning message.
            keyResponseParams.Add("API status", response.responseEnvelope.ack.ToString());

            // Correlation identifier. It is a 13-character,
            // alphanumeric string (for example, db87c705a910e) that is used
            // only by PayPal Merchant Technical Support.
            // Note: You must log and store this data for every response you receive.
            // PayPal Technical Support uses the information to assist with reported issues.
            keyResponseParams.Add("correlationId", response.responseEnvelope.correlationId);

            // ID of the updated invoice.
            keyResponseParams.Add("invoiceId", response.invoiceID);

            // Invoice number of the updated invoice.
            keyResponseParams.Add("invoiceNumber", response.invoiceNumber);

            // URL location where merchants view the updated invoice details.
            keyResponseParams.Add("invoiceUrl", response.invoiceURL);

            // The total amount of the invoice.
            keyResponseParams.Add("totalAmount", response.totalAmount.ToString());
            displayResponse(context, "UpdateInvoice", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), response.error, null);
        }
Example #4
0
 /**
  	  * Constructor with arguments
  	  */
 public UpdateInvoiceRequest(RequestEnvelope requestEnvelope, string invoiceID, InvoiceType invoice)
 {
     this.requestEnvelope = requestEnvelope;
     this.invoiceID = invoiceID;
     this.invoice = invoice;
 }
Example #5
0
 /**
  	  * Constructor with arguments
  	  */
 public CreateInvoiceRequest(RequestEnvelope requestEnvelope, InvoiceType invoice)
 {
     this.requestEnvelope = requestEnvelope;
     this.invoice = invoice;
 }
Example #6
0
        /// <summary>
        /// API call example for UpdateInvoice
        /// </summary>
        /// <param name="context"></param>
        private void UpdateInvoice(HttpContext context)
        {
            // Collect input params
            String invoiceId = context.Request.Params["invoiceId"];
            String merchantEmail = context.Request.Params["merchantEmail"];
            String payerEmail = context.Request.Params["payerEmail"];
            PaymentTermsType paymentTerms = (PaymentTermsType) Enum.Parse(
                    typeof(PaymentTermsType), context.Request.Params["paymentTerms"]);
            String item_name1 = context.Request.Params["item_name1"];
            String item_quantity1 = context.Request.Params["item_quantity1"];
            String item_unitPrice1 = context.Request.Params["item_unitPrice1"];
            String item_name2 = context.Request.Params["item_name2"];
            String item_quantity2 = context.Request.Params["item_quantity2"];
            String item_unitPrice2 = context.Request.Params["item_unitPrice2"];
            String currencyCode = context.Request.Params["currencyCode"];

            InvoiceItemListType itemList = new InvoiceItemListType();
            itemList.item = new List<InvoiceItemType>();
            itemList.item.Add(new InvoiceItemType(
                        item_name1,
                        decimal.Parse(item_quantity1),
                        decimal.Parse(item_unitPrice1)));
            itemList.item.Add(new InvoiceItemType(
                        item_name2,
                        decimal.Parse(item_quantity2),
                        decimal.Parse(item_unitPrice2)));
            InvoiceType invoice = new InvoiceType(merchantEmail, payerEmail, itemList,
                currencyCode, paymentTerms);
            UpdateInvoiceRequest request = new UpdateInvoiceRequest(
                new RequestEnvelope(ERROR_LANGUAGE), invoiceId, invoice);

            // Create service object and make the API call
            InvoiceService service = getService(context);
            UpdateInvoiceResponse response = service.UpdateInvoice(request);

            // Process response
            context.Response.Write("<html><body><textarea rows=30 cols=80>");
            ObjectDumper.Write(response, 5, context.Response.Output);
            context.Response.Write("</textarea></body></html>");
        }