The request object for CreateInvoice.
예제 #1
0
        /**
         *
         */
        public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest CreateInvoiceRequest, string apiUsername)
        {
            string resp = call("CreateInvoice", CreateInvoiceRequest.toNVPString(""), apiUsername);

            NVPUtil util = new NVPUtil();
            return new CreateInvoiceResponse(util.parseNVPString(resp), "");
        }
예제 #2
0
        public void createInvoiceRequestSerialization()
        {
            CreateInvoiceRequest cir = new CreateInvoiceRequest();
            cir.invoice = this.invoice;
            cir.requestEnvelope = new RequestEnvelope("en_US");

            string expectedNVPString = "requestEnvelope.errorLanguage=en_US&invoice.merchantEmail=jb-us-seller1%40paypal.com&invoice.payerEmail=jbui-us-personal1%40paypal.com&invoice.number=FD-123-5421&"
                + "invoice.currencyCode=USD&invoice.invoiceDate=2011-10-04T00%3a00%3a00&invoice.dueDate=2011-11-04T00%3a00%3a00&invoice.paymentTerms=Net45&invoice.discountPercent=5&"
                + "invoice.discountAmount=10.0&invoice.terms=Payment+terms&invoice.note=Note+about+invoice&invoice.merchantMemo=memo&"
                + "invoice.billingInfo.firstName=Bonzop&invoice.billingInfo.lastName=Zaius&invoice.billingInfo.businessName=Bonzop+Inc&invoice.billingInfo.phone=5126914160&invoice.billingInfo.fax=5126914161&invoice.billingInfo.website=www.bonzop-inc.com&invoice.billingInfo.customValue=Business+mumbo+jumbo+%c2%a9&"
                + "invoice.shippingAmount=2.1&invoice.shippingTaxName=Bonzop+Inc&invoice.shippingTaxRate=1.2&";
            Assert.AreEqual(expectedNVPString, cir.ToNVPString(""));

            cir = new CreateInvoiceRequest(new RequestEnvelope("en_US"), invoice);
            Assert.AreEqual(expectedNVPString, cir.ToNVPString(""));
        }
예제 #3
0
        private void CreateInvoice(HttpContext context)
        {
            String merchantEmail = context.Request.Params["merchantEmail"];
            String currencyCode = context.Request.Params["currencyCode"];
            String payerEmail = context.Request.Params["payerEmail"];
            String paymentTerms = 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"];

            CreateInvoiceRequest cr = new CreateInvoiceRequest();
            cr.requestEnvelope = new RequestEnvelope(ERROR_LANGUAGE);

            cr.invoice = new InvoiceType();
            cr.invoice.currencyCode = currencyCode;
            cr.invoice.merchantEmail = merchantEmail;
            cr.invoice.payerEmail = payerEmail;
            cr.invoice.paymentTerms = (PaymentTermsType)
                Enum.Parse( typeof(PaymentTermsType), paymentTerms);

            cr.invoice.itemList = new InvoiceItemListType();
            cr.invoice.itemList.item = new List<InvoiceItemType>();
            cr.invoice.itemList.item.Add(
                new InvoiceItemType(item_name1, decimal.Parse(item_quantity1), decimal.Parse(item_unitPrice1)));
            cr.invoice.itemList.item.Add(
                new InvoiceItemType(item_name2, decimal.Parse(item_quantity2), decimal.Parse(item_unitPrice2)));

            InvoiceService service = null;
            CreateInvoiceResponse cir = null;
            try
            {
                service = getService(context);
                cir = service.CreateInvoice(cr);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();
            keyResponseParams.Add("API status", cir.responseEnvelope.ack.ToString());
            keyResponseParams.Add("correlationId", cir.responseEnvelope.correlationId);
            keyResponseParams.Add("invoiceId", cir.invoiceID);
            keyResponseParams.Add("invoiceNumber", cir.invoiceNumber);
            keyResponseParams.Add("invoiceUrl", cir.invoiceURL);
            keyResponseParams.Add("totalAmount", cir.totalAmount.ToString());
            displayResponse(context, "CreateInvoice", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), cir.error, null);
        }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        ///<param name="createInvoiceRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest createInvoiceRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, createInvoiceRequest.ToNVPString(string.Empty), ServiceName, "CreateInvoice", credential);
               	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "Invoice";

            NVPUtil util = new NVPUtil();
            return CreateInvoiceResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
        }
예제 #5
0
 /// <summary> 
 /// 
 /// </summary>
 ///<param name="createInvoiceRequest"></param>
 public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest createInvoiceRequest)
 {
     return CreateInvoice(createInvoiceRequest,(string) null);
 }
예제 #6
0
        public void Init()
        {
            this.cr = new CreateInvoiceRequest();
            cr.requestEnvelope = new RequestEnvelope();
            cr.requestEnvelope.errorLanguage = "en_US";
            cr.requestEnvelope.detailLevel = DetailLevelCode.RETURNALL;

            cr.invoice = new InvoiceType();
            cr.invoice.currencyCode = "USD";
            cr.invoice.merchantEmail = "*****@*****.**";
            cr.invoice.payerEmail = "*****@*****.**";
            cr.invoice.paymentTerms = PaymentTermsType.DUEONRECEIPT;
            cr.invoice.itemList = new InvoiceItemListType();
            cr.invoice.itemList.item = new List<InvoiceItemType>();
            cr.invoice.itemList.item.Add(new InvoiceItemType());
            cr.invoice.itemList.item[0].name = "product1";
            cr.invoice.itemList.item[0].quantity = 10;
            cr.invoice.itemList.item[0].unitPrice = 2;
        }
예제 #7
0
 /**
   *AUTO_GENERATED
  	  */
 public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest CreateInvoiceRequest)
 {
     return CreateInvoice(CreateInvoiceRequest, null);
 }
        private void CreateInvoice(HttpContext context)
        {
            // (Required) Merchant email address.
            string merchantEmail = context.Request.Params["merchantEmail"];

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

            //  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.
            string paymentTerms = 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"];

            InvoiceModelAlias.CreateInvoiceRequest cr = new InvoiceModelAlias.CreateInvoiceRequest();
            cr.requestEnvelope = 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.
            cr.requestEnvelope.errorLanguage = ERROR_LANGUAGE;

            cr.invoice = new InvoiceModelAlias.InvoiceType();
            cr.invoice.currencyCode = currencyCode;
            cr.invoice.merchantEmail = merchantEmail;
            cr.invoice.payerEmail = payerEmail;
            cr.invoice.paymentTerms = (InvoiceModelAlias.PaymentTermsType)
                Enum.Parse(typeof(InvoiceModelAlias.PaymentTermsType), paymentTerms);

            cr.invoice.itemList = new InvoiceModelAlias.InvoiceItemListType();
            cr.invoice.itemList.item = new List<InvoiceModelAlias.InvoiceItemType>();
            cr.invoice.itemList.item.Add(
                new InvoiceModelAlias.InvoiceItemType(item_name1, Convert.ToDecimal(item_quantity1), Convert.ToDecimal(item_unitPrice1)));
            cr.invoice.itemList.item.Add(
                new InvoiceModelAlias.InvoiceItemType(item_name2, Convert.ToDecimal(item_quantity2), Convert.ToDecimal(item_unitPrice2)));

            InvoiceAlias.InvoiceService service = null;
            InvoiceModelAlias.CreateInvoiceResponse cir = null;
            SignatureCredential cred = SetThirdPartyAuthorization(context);
            try
            {
                service = GetService(context);
                if (cred != null)
                {
                    cir = service.CreateInvoice(cr, cred);
                }
                else
                {
                    cir = service.CreateInvoice(cr);
                }
            }
            catch (System.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", cir.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", cir.responseEnvelope.correlationId);

            // ID of the created invoice.
            keyResponseParams.Add("invoiceId", cir.invoiceID);

            //Invoice number of the created invoice.
            keyResponseParams.Add("invoiceNumber", cir.invoiceNumber);

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

            // The total amount of the invoice.
            keyResponseParams.Add("totalAmount", cir.totalAmount.ToString());
            displayResponse(context, "CreateInvoice", keyResponseParams, service.getLastRequest(),
                service.getLastResponse(), cir.error, null);
        }
예제 #9
0
 /**
   *AUTO_GENERATED
  	  */
 public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest createInvoiceRequest, string apiUserName)
 {
     string response = Call("CreateInvoice", createInvoiceRequest.ToNVPString(""), apiUserName);
     NVPUtil util = new NVPUtil();
     return CreateInvoiceResponse.CreateInstance(util.ParseNVPString(response), "", -1);
 }
예제 #10
0
        private void CreateInvoice(HttpContext context)
        {
            String merchantEmail = context.Request.Params["merchantEmail"];
            String currencyCode = context.Request.Params["currencyCode"];
            String payerEmail = context.Request.Params["payerEmail"];
            String paymentTerms = 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"];

            CreateInvoiceRequest cr = new CreateInvoiceRequest();
            cr.requestEnvelope = new RequestEnvelope(ERROR_LANGUAGE);

            cr.invoice = new InvoiceType();
            cr.invoice.currencyCode = currencyCode;
            cr.invoice.merchantEmail = merchantEmail;
            cr.invoice.payerEmail = payerEmail;
            cr.invoice.paymentTerms = (PaymentTermsType)
                Enum.Parse( typeof(PaymentTermsType), paymentTerms);

            cr.invoice.itemList = new InvoiceItemListType();
            cr.invoice.itemList.item = new List<InvoiceItemType>();
            cr.invoice.itemList.item.Add(
                new InvoiceItemType(item_name1, decimal.Parse(item_quantity1), decimal.Parse(item_unitPrice1)));
            cr.invoice.itemList.item.Add(
                new InvoiceItemType(item_name2, decimal.Parse(item_quantity2), decimal.Parse(item_unitPrice2)));
            CreateInvoiceResponse cir = null;

            try
            {
                InvoiceService service = getService(context);
                cir = service.CreateInvoice(cr);
                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(cir, 5, context.Response.Output);
                context.Response.Write("</textarea></body></html>");
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
            }
        }
 /**
   *AUTO_GENERATED
  	  */
 public CreateInvoiceResponse CreateInvoice(CreateInvoiceRequest createInvoiceRequest, string apiUserName)
 {
     IAPICallPreHandler apiCallPreHandler = null;
     apiCallPreHandler = new PlatformAPICallPreHandler(createInvoiceRequest.ToNVPString(string.Empty), ServiceName, "CreateInvoice", apiUserName, getAccessToken(), getAccessTokenSecret());
        	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     string response = Call(apiCallPreHandler);
     NVPUtil util = new NVPUtil();
     return CreateInvoiceResponse.CreateInstance(util.ParseNVPString(response), string.Empty, -1);
 }