TriPSs / Moneybird-API

Moneybird API client for PHP
MIT License
4 stars 1 forks source link

Send Invoice after Creating #2

Closed Jaspur closed 5 years ago

Jaspur commented 5 years ago

Hi @TriPSs,

How to send the invoice after creating it?

I tried:

$moneybirdInvoice = $moneybirdClient->salesInvoices->create($nInvoice);
$moneybirdClient->salesInvoices->send($nInvoice);
TriPSs commented 5 years ago

Hi @Jaspur:

Can you try to send the $moneybirdInvoice instead of $nInvoice:

$moneybirdClient->salesInvoices->send($moneybirdInvoice);
Jaspur commented 5 years ago

Hi @TriPSs, That's a quick reply :-) Just tried it and that's also not working.

TriPSs commented 5 years ago

Do you get any logs / response from $moneybirdClient->salesInvoices->send($moneybirdInvoice);?

And could you check with $moneybirdClient->getLastHttpResponseStatusCode() what the last code returned by Moneybird is?

And if possible can you share a little more of your setup code?

TriPSs commented 5 years ago

And is the invoice created with $moneybirdClient->salesInvoices->create($nInvoice);?

Jaspur commented 5 years ago

Found a response: Error executing API call: Sales Invoice Sending isn't a hash.

Jaspur commented 5 years ago

@TriPSs got an answer from Moneybird about this and they say:

Bedankt voor je bericht. Als je deze foutmelding krijgt, dan geef je de parameters niet in het goede formaat mee. Je kunt hier nalezen op in welk formaat je ze mee kunt geven aan je request: https://developer.moneybird.com/api/sales_invoices/#patch_sales_invoices_id_send_invoice

You have a clue what to do?

TriPSs commented 5 years ago

Hi @Jaspur, I will see if I can repreduce the error as I do not use this project somewhere anymore I will need to setup something.

TriPSs commented 5 years ago

Hi @Jaspur, i committed a couple of changes, the following way now works again:

$salesInvoice = $moneybirdClient->salesInvoices->send("INVOICE ID");

The default send method of the contact is used, to overwrite use the below, that was a way that already worked:

$invoiceContact = new \Moneybird\Object\Contact();
$invoiceContact->id = "CONTACT ID";
$invoiceContact->delivery_method = "Email";
$invoiceContact->email = "your@email.com";

$salesInvoice = $moneybirdClient->salesInvoices->setContact($invoiceContact);
$salesInvoice->send("INVOICE ID");
Jaspur commented 5 years ago

@TriPSs thanks, it's working now!