1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #6698 from turbo124/v5-develop

Minor fixes for braintree
This commit is contained in:
David Bomba 2021-09-22 12:03:04 +10:00 committed by GitHub
commit e621ad34ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -55,7 +55,10 @@ class CompanyGatewayObserver
public function restored(CompanyGateway $company_gateway)
{
//When we restore the gateway, bring back the tokens!
ClientGatewayToken::where('company_gateway_id', $company_gateway->id)->withTrashed()->get()->restore();
ClientGatewayToken::where('company_gateway_id', $company_gateway->id)
->withTrashed()->cursor()->each(function ($cgt){
$cgt->restore();
});
}
/**

View File

@ -151,6 +151,11 @@ class CreditCard
],
];
if ($this->braintree->company_gateway->getConfigField('merchantAccountId')) {
/** https://developer.paypal.com/braintree/docs/reference/request/transaction/sale/php#full-example */
$data['merchantAccountId'] = $this->braintree->company_gateway->getConfigField('merchantAccountId');
}
$response = $this->braintree->gateway->paymentMethod()->create($data);
if ($response->success) {

View File

@ -283,9 +283,6 @@ class Statement
$from = $ranges[0];
$to = $ranges[1];
nlog("from ".$from->format("Y-m-d"));
nlog("to ".$to->format("Y-m-d"));
$client = Client::where('id', $this->client->id)->first();
$amount = Invoice::where('company_id', $this->client->company->id)

View File

@ -70,7 +70,7 @@ class AutoBillInvoice extends AbstractService
/* Determine $amount */
if ($this->invoice->partial > 0) {
$is_partial = true;
$invoice_total = $this->invoice->amount;
$invoice_total = $this->invoice->balance;
$amount = $this->invoice->partial;
} elseif ($this->invoice->balance > 0) {
$amount = $this->invoice->balance;
@ -94,10 +94,14 @@ class AutoBillInvoice extends AbstractService
/* $gateway fee */
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
//change from $this->invoice->amount to $this->invoice->balance
if($is_partial)
$fee = $this->invoice->amount - $invoice_total;
$fee = $this->invoice->balance - $invoice_total;
else
$fee = $this->invoice->amount - $amount;
$fee = $this->invoice->balance - $amount;
if($fee > $amount)
$fee = 0;
/* Build payment hash */
$payment_hash = PaymentHash::create([