0

Can I get the invoice URL using XeroCoreApi in C#?

I have the following code that mark an invoice as paid after the payment is processed by the payment gateway. I want to redirect the user to the invoice.

Payment payment = new Payment();
Invoice payingInvoice = _api.Invoices.Find("xyz");

payment.Invoice = payingInvoice;
Account payingAccount = new Account();
payingAccount.Code = "xyz";
payment.Account = payingAccount;
payment.Amount = "xyz";
payment.Date = DateTime.Now;
_api.Payments.Create(payment);
Response.Redirect("INVOICE_URL"); //Here should be the Invoice URL
Eduardo Yáñez Parareda
  • 9,126
  • 4
  • 37
  • 50
Hatem Husam
  • 177
  • 1
  • 3
  • 14

1 Answers1

1

You can build up the invoice url using the organisation short code (from the organisation endpoint) and the id of the invoice like so:

https://go.xero.com/organisationlogin/default.aspx?shortcode={ORG_SHORTCODE}&redirecturl=/AccountsReceivable/View.aspx?InvoiceID={INVOICE_ID}

This is called deep linking and is documented here:

https://developer.xero.com/documentation/api-guides/deep-link-xero

rustyskates
  • 856
  • 4
  • 10
  • Thank you @rustyskates, I reviewed that option before posting this question but I think it will be easier to get the link directly through XeroCoreApi is possible. – Hatem Husam Aug 04 '19 at 12:27