/** * AUTO_GENERATED */ public CreateAndSendInvoiceResponse CreateAndSendInvoice(CreateAndSendInvoiceRequest createAndSendInvoiceRequest, string apiUserName) { string response = Call("CreateAndSendInvoice", createAndSendInvoiceRequest.ToNVPString(""), apiUserName); NVPUtil util = new NVPUtil(); return(CreateAndSendInvoiceResponse.CreateInstance(util.ParseNVPString(response), "", -1)); }
public void CreateAndSendInvoice() { CreateAndSendInvoiceSample sample = new CreateAndSendInvoiceSample(); CreateAndSendInvoiceResponse responseCreateAndSendInvoice = sample.CreateAndSendInvoiceAPIOperation(); Assert.IsNotNull(responseCreateAndSendInvoice); Assert.AreEqual(responseCreateAndSendInvoice.responseEnvelope.ack.ToString().Trim().ToUpper(), "SUCCESS"); Assert.IsNotNull(responseCreateAndSendInvoice.invoiceID); }
public void createAndSendInvoiceResponseConstruction() { CreateAndSendInvoiceResponse cir = CreateAndSendInvoiceResponse.CreateInstance(validCreateInvoiceResponse, "", -1); Assert.AreEqual("INV2-PCWG-P78G-7EYV-94QY", cir.invoiceID); Assert.AreEqual("0056", cir.invoiceNumber); Assert.AreEqual(AckCode.SUCCESS, cir.responseEnvelope.ack); Assert.AreEqual("1917403", cir.responseEnvelope.build); Assert.AreEqual("9b3bb0a44d852", cir.responseEnvelope.correlationId); Assert.AreEqual("2011-05-30T03:31:18.988-07:00", cir.responseEnvelope.timestamp); }
/// <summary> /// /// </summary> ///<param name="createAndSendInvoiceRequest"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public CreateAndSendInvoiceResponse CreateAndSendInvoice(CreateAndSendInvoiceRequest createAndSendInvoiceRequest, ICredential credential) { IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, createAndSendInvoiceRequest.ToNVPString(string.Empty), ServiceName, "CreateAndSendInvoice", credential); ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName = SDKName; ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion; ((PlatformAPICallPreHandler)apiCallPreHandler).PortName = "Invoice"; NVPUtil util = new NVPUtil(); return(CreateAndSendInvoiceResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1)); }
public void CreateAndSendInvoiceTest() { CreateAndSendInvoiceRequest cr = new CreateAndSendInvoiceRequest(); 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; CreateAndSendInvoiceResponse cir = null; try { InvoiceService service = new InvoiceService(); cir = service.CreateAndSendInvoice(cr); } catch (System.Exception e) { Console.Write(e.Message); Assert.Fail(e.Message); } Assert.AreEqual(AckCode.SUCCESS, cir.responseEnvelope.ack); Assert.IsNotNull(cir.invoiceNumber); Assert.IsNotNull(cir.invoiceID); }
private void CreateAndSendInvoice(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"]; CreateAndSendInvoiceRequest cr = new CreateAndSendInvoiceRequest(); 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.DUEONRECEIPT; 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; CreateAndSendInvoiceResponse cir = null; try { service = getService(context); cir = service.CreateAndSendInvoice(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, "CreateAndSendInvoice", keyResponseParams, service.getLastRequest(), service.getLastResponse(), cir.error, null); }
// # CreateAndSendInvoice API Operation // Use the CreateAndSendInvoice API operation to create and send an invoice. public CreateAndSendInvoiceResponse CreateAndSendInvoiceAPIOperation() { // Create the CreateAndSendInvoiceResponse object CreateAndSendInvoiceResponse responseCreateAndSendInvoice = new CreateAndSendInvoiceResponse(); try { // # CreateAndSendInvoiceRequest // Use the CreateAndSendInvoiceRequest message to create and send a new // invoice. The requester should authenticate the caller and verify that // the merchant requesting the invoice has an existing PayPal account in // good standing. Once the invoice is created, PayPal sends it to the // specified payer, who is notified of the pending invoice. // The code for the language in which errors are returned, which must be // en_US. RequestEnvelope envelopeRequest = new RequestEnvelope(); envelopeRequest.errorLanguage = "en_US"; List <InvoiceItemType> invoiceItemList = new List <InvoiceItemType>(); // InvoiceItemType which takes mandatory params: // // * `Item Name` - SKU or name of the item. // * `Quantity` - Item count. // * `Amount` - Price of the item, in the currency specified by the // invoice. InvoiceItemType invoiceItem = new InvoiceItemType("Item", Convert.ToDecimal("2"), Convert.ToDecimal("4.00")); invoiceItemList.Add(invoiceItem); // Invoice item. InvoiceItemListType itemList = new InvoiceItemListType(invoiceItemList); // InvoiceType which takes mandatory params: // // * `Merchant Email` - Merchant email address. // * `Personal Email` - Payer email address. // * `InvoiceItemList` - List of items included in this invoice. // * `CurrencyCode` - Currency used for all invoice item amounts and // totals. // * `PaymentTerms` - 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. InvoiceType invoice = new InvoiceType("*****@*****.**", "*****@*****.**", itemList, "USD", PaymentTermsType.DUEONRECEIPT); // CreateAndSendInvoiceRequest which takes mandatory params: // // * `Request Envelope` - Information common to each API operation, such // as the language in which an error message is returned. // * `Invoice` - Merchant, payer, and invoice information. CreateAndSendInvoiceRequest requestCreateAndSendInvoice = new CreateAndSendInvoiceRequest(envelopeRequest, invoice); // Create the service wrapper object to make the API call InvoiceService service = new InvoiceService(); // # API call // Invoke the CreateAndSendInvoice method in service responseCreateAndSendInvoice = service.CreateAndSendInvoice(requestCreateAndSendInvoice); if (responseCreateAndSendInvoice != null) { // Response envelope acknowledgement string acknowledgement = "CreateAndSendInvoice API Operation - "; acknowledgement += responseCreateAndSendInvoice.responseEnvelope.ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseCreateAndSendInvoice.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // ID of the created invoice. logger.Info("Invoice ID : " + responseCreateAndSendInvoice.invoiceID + "\n"); Console.WriteLine("Invoice ID : " + responseCreateAndSendInvoice.invoiceID + "\n"); } // # Error Values else { List <ErrorData> errorMessages = responseCreateAndSendInvoice.error; foreach (ErrorData error in errorMessages) { logger.Debug("API Error Message : " + error.message + "\n"); Console.WriteLine("API Error Message : " + error.message + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return(responseCreateAndSendInvoice); }