public Invoice SendInvoice(string email, string reference, string totalamount, string currency) { var apiContext = GetApiContext(); var TemplateInvoice = InvoiceTemplate.Get(apiContext, "TEMP-7V015177YY181050W"); var TemplateInfo = TemplateInvoice.template_data; var item = TemplateInfo.items; var invoice = new Invoice { merchant_info = TemplateInfo.merchant_info, billing_info = new List <BillingInfo> { new BillingInfo { email = email }, }, items = new List <InvoiceItem> { new InvoiceItem { name = "Digital Goods", quantity = 1, unit_price = new Currency { currency = currency, value = totalamount, }, tax = new Tax { name = "Service fees", percent = (float)5.85 }, }, }, logo_url = TemplateInfo.logo_url, terms = TemplateInfo.terms, reference = reference, note = TemplateInfo.note, template_id = TemplateInvoice.template_id }; var createdInvoice = invoice.Create(GetApiContext()); createdInvoice.Send(GetApiContext()); return(createdInvoice); }
protected override void RunSample() { // ### Api Context // Pass in a `APIContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext. var apiContext = Configuration.GetAPIContext(); var invoiceTemplate = new InvoiceTemplate() { name = "Template " + Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), @default = true, unit_of_measure = "HOURS", template_data = new InvoiceTemplateData() { items = new List <InvoiceItem>() { new InvoiceItem() { name = "Nutri Bullet", quantity = 1.0F, unit_price = new Currency() { currency = "USD", value = "50.00" } } }, merchant_info = new MerchantInfo() { email = "*****@*****.**" }, tax_calculated_after_discount = false, tax_inclusive = false, note = "Thank you for your business", logo_url = "https://pics.paypal.com/v1/images/redDot.jpeg", }, settings = new List <InvoiceTemplateSettings>() { new InvoiceTemplateSettings() { field_name = "items.date", display_preference = new InvoiceTemplateSettingsMetadata() { hidden = true } }, new InvoiceTemplateSettings() { field_name = "custom", display_preference = new InvoiceTemplateSettingsMetadata() { hidden = true } } } }; // ^ Ignore workflow code segment #region Track Workflow this.flow.AddNewRequest("Create the template.", invoiceTemplate); #endregion // Create the invoice template var createdTemplate = invoiceTemplate.Create(apiContext); // ^ Ignore workflow code segment #region Track Workflow this.flow.RecordResponse(createdTemplate); #endregion // ^ Ignore workflow code segment #region Track Workflow this.flow.AddNewRequest("Retrieve the template."); #endregion // Retrieve the invoice template var retrievedTemplate = InvoiceTemplate.Get(apiContext, createdTemplate.template_id); // ^ Ignore workflow code segment #region Track Workflow this.flow.RecordResponse(retrievedTemplate); #endregion // For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/). }