Happy Business Starts Here

Student dj
Student

How do I show all the invoices with name of the item/subscription that was purchased?

Right now I am calling `/v1/transactions/invoices/accounts/#{account_key}` to get the account list which gives results as - 

{
  "invoices" => [{
    "id" => "8adc9a416684dbf30166a5f0d6c570d5",
    "accountId" => "8adc9a416684dbf30166a5bcb7346954",
    "accountNumber" => "8989",
    "accountName" => "my_account1",
    "invoiceDate" => "2018-10-24",
    "invoiceNumber" => "INV00000021",
    "dueDate" => "2018-10-24",
    "invoiceTargetDate" => "2018-10-24",
    "amount" => 39.0,
    "balance" => 0.0,
    "creditBalanceAdjustmentAmount" => 0.0,
    "createdBy" => "8adc8f996684dbfe0166a0464ef145e5",
    "status" => "Posted",
    "body" => "/v1/files/8adcb9fe668a890e0166a5f0f1675d10",
    "invoiceItems" => "/v1/invoices/8adc9a416684dbf30166a5f0d6c570d5/items",
    "invoiceFiles" => "/v1/invoices/8adc9a416684dbf30166a5f0d6c570d5/files"
  }

out of which, I need to take the id and pass it to - /v1/invoices/8adcc59c6684e41e0166a5ed8a2e5d25/items which finally gives me name of the item purchased. I can't make an API call for each invoice item, that would be an overkill.

{
  "invoiceItems" => [{
    "id" => "8adcc59c6684e41e0166a5ed8a365d27",
    "subscriptionName" => "A-S00000097",
    "subscriptionId" => "8adcc59c6684e41e0166a5ed889f5cfb",
    "serviceStartDate" => "2018-10-24",
    "serviceEndDate" => "2018-11-23",
    "chargeAmount" => 129.0,
    "chargeDescription" => "",
    "chargeName" => "Myproduct5u_2p",
    "chargeId" => "8adcc59c6684e41e0166a5ed88e35d06",
    "productName" => "Product1",
    "quantity" => 1.0,
    "taxAmount" => 0.0,
    "unitOfMeasure" => "",
    "chargeDate" => "2018-10-24 11:55:00",
    "chargeType" => "Recurring",
    "processingType" => "Charge"
  }

Is there an easier way to do the same?

Tags (2)
2 REPLIES 2
Support SME

Re: How do I show all the invoices with name of the item/subscription that was purchased?

Hi @dj

 

If you use this call - /v1/invoices/8adcc59c6684e41e0166a5ed8a2e5d25/items, it will give you a list of all the items of this invoice, not a single invoice item, so you do not need to query a particular invoice a lot of times to get all its items. Could you find an invoice with more than one items and try again? Thanks!

 

Highlighted
Student dj
Student

Re: How do I show all the invoices with name of the item/subscription that was purchased?

I want to list all the invoices, item purchased in that invoice, and its download link.

I get invoices for an account from - /v1/transactions/invoices/accounts/#{account_key}

While fetching invoice I get the download link in 'body' but I don't get the productName which I have to get for an individual invoice using - /v1/invoices/8adcc59c6684e41e0166a5ed8a2e5d25/items.

"productName" => "Product1",

Would be great if I could get that in first call (/v1/transactions/invoices/accounts/#{account_key}) itself.