Closed t2thec closed 8 years ago
@movostudios what Laravel wrapper are you using? Is it open source? It's going to be pretty much impossible to figure this out without access to that code.
Thanks @gerrywastaken. The wrapper is: https://github.com/drawmyattention/xerolaravel
Basically it is a simple wrapper to bind this package into Laravel's IOC container. So in essence, the code here is what we are working with. The example above just has things like App::make
which is creating the object... so to speak. I've also added it drawmyattention/xerolaravel
to create a XeroPayment object as the original dev hadn't created that.
The issue I have really is that looking at the code here at calcinai/xero-php
I can't see a way in Models/Accounting/Payment
to ->save
or in Models/Accounting/Invoice
to attach the payment to the invoice object. Does that all make sense? What is the best approach for this?
Thanks again
I couldn't get the wrapper to work, but I might be able to take a stab in the dark at what is wrong...
Instead of
$payment->setInvoice($xero_invoice);
try:
$payment->setInvoice($invoice->guid);
The setInvoice()
method expects an invoice object, so I don't think @gerrywastaken's solution will work.
This could be related to the state changes allowed by Xero. There have been similar issues a while ago in #28
Have you tried it in the API previewer?
@calcinai Thanks. I must have been half asleep while looking at that code.
Thanks @calcinai and @gerrywastaken - The issue I seem to be having is that in Payment
class, there is no setPayment
method. There is a setPrepayment
. In the Invoice
class, there is also no way to setPayment
either.
I can create a Payment object however the main issue is that I can't seem to find a way to send it to Xero. There is no send($payment)
or a way to attach it to the invoice that I can see. If I save it on the Xero object (as per my OP) I get the following weird error:
A validation exception occurred (An error occurred in Xero. Check the API Status page http://status.developer.xero.com for current service status. Contact the API support team at api@xero.com for more assistance)
Thanks again for the help. Do you guys have any examples of how you have sent payments? I should be able to figure it out from there.
Cheers
I just did one up like this.
$invoice = $this->xero->loadByGUID('Accounting\\Invoice', '65dc4bc9-b88a-4adc-b965-ca64b5e2880f');
$account = $this->xero->loadByGUID('Accounting\\Account', '13918178-849a-4823-9a31-57b7eac713d7');
$payment = new \XeroPHP\Models\Accounting\Payment($this->xero);
$payment
->setAccount($account)
->setInvoice($invoice)
->setCurrencyRate(1)
->setAmount($invoice->total);
$payment->save();
The issue I seem to be having is that in Payment class, there is no setPayment method
setPayment on a Payment? Did you mean the Invoice class? Xero doesn't allow you to link up a payment via the Invoice endpoint, but does allow setting an invoice link via the Payment endpoint (as shown in my example above).
Thanks @gerrywastaken. Yeah, sorry, I did mean the Invoice class.
The only thing I haven't done here is to set the account as per your example. I will give that a go and see how we get on.
One again, thanks very much!!
@movostudios how'd you get on?
TBH I haven't had a chance to get back to it yet. I have time booked in for this client later today, so I will take a look then. Thanks very much @calcinai
Is this able to be closed?
Sorry @calcinai. I had been pulled off to a different project. I am back on it this week so will get a chance to check. I'm sure it is fine though, so I will mark as closed.
Thanks @calcinai and @gerrywastaken for your support on this. Very much appreciated.
Hi ya,
I am using a wrapper for this awesome package to work through Laravel. I have been reading up and can't seem to make a payment on an invoice so that it is marked as PAID.
The Payment object is being created and the Invoice is correct too. However, I can't seem to get the above to work. I get a
BadRequestException
:The status of Xero is fine. So I am guessing that something is amiss with the request?
I've been through the code of the package and can't seem to see a way to
setPayments
on an invoice. Am I going about this the wrong way? Any tips on paying an invoice?Thanks a lot for putting the package together.