Setting the Payment Type via the API and php SDK

Version v5.10.48

I am using your PHP SDK from here GitHub - invoiceninja/sdk-php: PHP wrapper for Invoice Ninja's REST API
All works well, of creating clients, invoices, payments, etc

a snippet of my code is

// Mark as paid if requested
if ($markAsPaid) {
$options[‘paid’] = ‘true’;
$options[‘amount_paid’] = $billingAmount;
}

// create the invoice
$invoice = $this->client->invoices->create($invoiceData, $options);

this works fine, but i notice that within the Invoice Ninja app, this marks the payment as “Manual entry”
I have looked through the documentation and code but am failing to find any means of setting the “payment type”
For my needs, i would like to set it to “credit card other” as this is the closest match

Could you point me in the right direction or advise on how i can do this please?

In addition it would be of use to me if i were able to add in other payment types. i have looked through the settings, but cannot find any where i can add a payment type. Is this possible?
I wonder if i could just add them to the database? or would this cause problems in other places and possibly get overwritten with updates, etc.

Any help on this also would be greatly appreciated

Jon

Hi,

This requests creates an invoice and payment together, I think you’d need to use the API to change the payment type after it’s been created.

Feel free to create an issue on GitHub to request a new payment type. We don’t recommend manually adding payment types in the database, any manual changes to the database can cause issues.

1 Like

thank you very much

i am looking into “$this->client->invoices->bulk()” to set the payment after invoice creation (and without marking it as payed on creation), however i am struggling to understand what i can pass to this method from the documentation here Invoice Ninja API Documentation

ChatGPT is suggesting i can pass it the key of “payment_type_id”. ChatGPT seems rather confident in this, but i cannot find it in the documentation.

my issue is, this is a production environment, so i am unsure on this (i can put it back into test environment, but this will take time, so was hoping to get it correct first time :wink: and test live!)

I hear you on not adding payment types direct to the DB, “credit card other” will be acceptable for me at the moment.

thank you for your support and invoiceNinja

Jon

I believe this is the route you want to use:

https://api-docs.invoicing.co/#tag/payments/PUT/api/v1/payments/{id}

Note: you can use the network tab in the browser console to see the API requests sent by the app. I suggest viewing the network tab, clearing all requests and then updating the status in the app.

1 Like