"Buy Now" button, get invoice ID

So when use clicks the “Buy Now” with a email already assigned to it, for example I’m using the link, they get redirected to Invoice Ninja where they can make the payment. How do I track the payment?

So on my Dashboard (Vanilla PHP), I plan to use the API to get the invoice according to the invoice ID created by the “Buy Now” and than check if the payment was made. Is this possible?

Another question for the invoice_status_id i understand “1” is incomplete and “6” is complete, are there any others?

One solution may be to add a subscription to be notified when a payment is created.

https://www.invoiceninja.com/api-documentation/ (bottom of the page)

mysql> select * from invoice_statuses;
+----+----------+
| id | name     |
+----+----------+
|  1 | Draft    |
|  2 | Sent     |
|  3 | Viewed   |
|  4 | Approved |
|  5 | Partial  |
|  6 | Paid     |
+----+----------+

How would I go about doing that.

Is there no other way though?

All users that register on my site as registered on invoice ninja via API.

Also how do I reset the client ID, while testing it I made some users and deleted them, but the users now start from like client number 20. Nothing is archived.

Back to the point, is there no way for me to trace that user’s invoice number?

Thank you

You could check for payments using the API.

In a future version we plan to add a redirect URL which will hopefully simplify this use case.

Yeah that would be amazing.

So our client ID is getting messed up, can we order the invoice by email? No 2 clients should have the same email.

Buy now buttons are meant for one-off purchases, you may want to use the API to ensure only one client record is created.

So I’m thinking now.

Here is my new plan:

Client clicks buy --> API creates invoice based on client’s Email from SQL database and the Product ID

Than the client is asked to check his/her email or is there a option in the API where I can retrieve the URL for the client?

than the client pays, they go on our site, presses “I’ve Paid”, we call the API, check the invoice status by the invoice ID and if it is paid we update our SQL as paid, if not we say, Sorry you haven’t paid.

Would that work? Could you help me if the part I put in bold.

That seems like it would work, if you run into any problems we’re happy to help.

When you create the invoice (or when loading it) you can add ?include=invitations to the URL to get back the link.

As previously mentioned subscriptions may enable you to remove the “I’ve paid” step.

Thanks for that, but how does the frequency ID work?
I looked on the control panel and it just said Due Date: 24th day of the month or whatever you select, is that it?

  1. It also seems that when I create a invoice through the API it doesn’t send the email.

curl -X POST -H "X-Ninja-Token: TOKEN" -H "X-Requested-With: XMLHttpRequest" -H "Content-Type: application/json"-d '{"client_id":"18", "invoice_items":[{"product_key": "Server", "qty":1}]}' "https://app.invoiceninja.com/api/v1/invoices/?include=invitations"

I posted the response on Pastebin.

It said the email was sent but no date was given.

  1. Also Where is the Invoice number? One says 19 and the other says 20

In the control panel it says the invoice number is 18

  1. Also can I reset my clients and invoice so when I create a new invoice or client it starts from 0? It seems like it is soft deleting them.

I know this is long but thank you

  1. Try adding email_invoice=true to the URL to send and create at the same time.

  2. I’m not sure I understand, the invoice number should be returned in the response.

  3. To enforce referential integrity we only support soft-deleting, you need to re-create the account to fully delete data.

Alright Thanks. I’ll reply again when I have more questions! You’ve been a great help

Hi,

If I create a invoice, and make the put ?include=invitations, but in my setting I put that Invoice Ninja automatically generates a password, how can I get the password on the response? I want to store it on the SQL server, I am also sending it to the user using email_invoice=true

Thank you

The simplest approach is to set due_date_sql and pass the date as 2016-10-26.

Hi, I figured that out I just use strtotime to add 1 day to the current day.

However the other problem…

If I create a invoice, and make the put ?include=invitations, but in my setting I put that Invoice Ninja automatically generates a password, how can I get the password on the response? I want to store it on the SQL server, I am also sending it to the user using email_invoice=true

You can use ?include=invitations,client to include the client in the response.

We don’t currently show the contact password in the API but you can add it here:

https://github.com/invoiceninja/invoiceninja/blob/master/app/Ninja/Transformers/ContactTransformer.php

I’m hosting on Invoice Ninja is there any future plans to add this as a functionality?

Thanks

We can add this in our next release in about a month.

For now maybe you can set the password when you create the client/contact.

FYI… we won’t be able to add the password field, we use a one-way encryption so don’t know it once it’s been sent.

You’ll need to manually set the password when creating the client.

The API seems to limit my results and sends it to a link on page 2…

Is there any way to remove this?

This is when viewing invoices