Integromat and Apply Payment

I’ve used Integromat with Invoice Ninja and it worked fine on V4. Now that we’ve upgraded to V5, I need to rebuild the Integromat integrations with the new Invoice Ninja modules (V2 vs. V1).

However, I’ve run into an issue with the Payments:
The Create a Payment module has a reference to the Client ID, but not to the Invoice ID. All invoices that are created show up as Drafts, with the balance still due. I have unconnected Payments, too, but I need to go manually into the website and “apply” these payments to the invoices.

What do I need to do to have these payments be applied to the corresponding invoices automatically?
Or how else can I mark these invoices as paid?

Thanks!

Just found another issue:
There used to be a module that was Watching the Payments. Whenever someone paid, the corresponding ticket in our case management tool would be updated with that information.

Now that doesn’t seem to work out of the box anymore?
“Watch New Payment” now just creates a webhook in Integromat, but to trigger that webhook I have to set it up in Invoice Ninja under Account Management, is that right?
But what do I need to enter there?
None of the “Event Types” seems correct. I don’t want to Create, Update, or Delete a Payment, I simply want to get it, then trigger an action in Integromat.

Hi,

We manage the Zapier integration ourselves however for help with the Integromat integration you’ll need to reach out to them directly.

I tried Zapier, but that doesn’t work either, since it allows only Create actions, but no updates.

So now I’m playing around with the API.
I can create an invoice. I can create a Payment.
But howwwww do I apply that payment to an invoice?
How do I update an invoice and mark it as paid?

To create a payment and apply it against an invoice you need to provide an “invoices” property.

{
    "invoices": [
        {
            "amount": 50,
            "invoice_id": "QJ0dN6dLOv",
        }
    ],
}

One approach to figure out how to send specific API requests is to use the admin portal to take the action and inspect the browser console to see the format of the request.

Thank you!

It tried that an I keep getting the same error:
[422] The given data was invalid. “client_id”: The client id field is required.

But here’s the JSON I’m sending: (with dynamic settings):
{
“id”: “{{40.client_id}}”,
“client_id”: “{{40.client_id}}”,
“date”: “{{28.created_at}}”,
“amount”: {{40.amount}},
“paymentables”: {
“client_id”: “{{40.client_id}}”,
“invoice_id”: “{{40.id}}”,
“amount”: 148,
},
“invoices”: [
{
“client_id”: “{{40.client_id}}”,
“invoice_id”: “{{40.id}}”,
“amount”: “147”
}
],
}

the actual JSON (without dynamic fields):
{
“id”: “Vyb841zjbv”,
“client_id”: “Vyb841zjbv”,
“date”: “2021-02-13T15:56:01.000Z”,
“amount”: 149,
“paymentables”: {
“invoice_id”: “GRb4gjOxaB”,
“amount”: 148,
},
“invoices”: [
{
“invoice_id”: “GRb4gjOxaB”,
“amount”: “147”
}
],
}

Method POST

I’m sending three different amounts to see which one is taken.

I also tried to create the Payment through the module first (which works), then updating that payment through PUT. But still I get the same error of 422] The given data was invalid. “client_id”: The client id field is required.

When I try to send the same JSON through Postman, I also get the error.

I actually copied the example JSON from the API doc to create a Payment (changing the IDs), and it still didn’t work.

Any hints?

@david do you have any suggestions?

@markus

Have you see the payments API here:

https://app.swaggerhub.com/apis/invoiceninja/invoiceninja/5.3.25#/payments/storePayment

Something like the below will work.

{
  "id": "Opnel5aKBz",
  "client_id": "Opnel5aKBz",
  "invitation_id": "Opnel5aKBz",
  "client_contact_id": "Opnel5aKBz",
  "user_id": "Opnel5aKBz",
  "type_id": "1",
  "date": "1-1-2014",
  "invoices": [
    {
      "invoice_id": "Opnel5aKBz",
      "amount": "2"
    }
  ],
  "credits": [
    {
      "credit_id": "Opnel5aKBz",
      "amount": "2"
    }
  ]
}


Another example from our test suite that will pass:

```php
        $data = [
            'amount' => $this->invoice->amount,
            'client_id' => $client->hashed_id,
            'invoices' => [
                [
                'invoice_id' => $this->invoice->hashed_id,
                'amount' => $this->invoice->amount,
                ],
            ],
            'date' => '2020/12/12',

        ];

There is no “storePayment” section at this page?

I just tried again, with POST to /v1/payments

{
“id”: “pnelG49rdK”
“client_id”: “pnelG49rdK”,
"invitatin_id: “pnelG49rdK”,
“user_id”: “JxboWnYbgw”,
“type”: 1,
“date”: “2021-02-13T15:56:01.000Z”,
“amount”: 149,
“paymentables”: {
“client_id”: “pnelG49rdK”,
“invoice_id”: “y1aKWGzYaQ”,
“amount”: 148,
},
“invoices”: [
{
“client_id”: “pnelG49rdK”,
“invoice_id”: “y1aKWGzYaQ”,
“amount”: “147”
}
],
}

Same error: [422] The given data was invalid. “client_id”: The client id field is required.