mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6698 from turbo124/v5-develop
Minor fixes for braintree
This commit is contained in:
commit
e621ad34ac
@ -55,7 +55,10 @@ class CompanyGatewayObserver
|
|||||||
public function restored(CompanyGateway $company_gateway)
|
public function restored(CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
//When we restore the gateway, bring back the tokens!
|
//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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
$response = $this->braintree->gateway->paymentMethod()->create($data);
|
||||||
|
|
||||||
if ($response->success) {
|
if ($response->success) {
|
||||||
|
@ -283,9 +283,6 @@ class Statement
|
|||||||
$from = $ranges[0];
|
$from = $ranges[0];
|
||||||
$to = $ranges[1];
|
$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();
|
$client = Client::where('id', $this->client->id)->first();
|
||||||
|
|
||||||
$amount = Invoice::where('company_id', $this->client->company->id)
|
$amount = Invoice::where('company_id', $this->client->company->id)
|
||||||
|
@ -70,7 +70,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
/* Determine $amount */
|
/* Determine $amount */
|
||||||
if ($this->invoice->partial > 0) {
|
if ($this->invoice->partial > 0) {
|
||||||
$is_partial = true;
|
$is_partial = true;
|
||||||
$invoice_total = $this->invoice->amount;
|
$invoice_total = $this->invoice->balance;
|
||||||
$amount = $this->invoice->partial;
|
$amount = $this->invoice->partial;
|
||||||
} elseif ($this->invoice->balance > 0) {
|
} elseif ($this->invoice->balance > 0) {
|
||||||
$amount = $this->invoice->balance;
|
$amount = $this->invoice->balance;
|
||||||
@ -94,10 +94,14 @@ class AutoBillInvoice extends AbstractService
|
|||||||
/* $gateway fee */
|
/* $gateway fee */
|
||||||
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
|
$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)
|
if($is_partial)
|
||||||
$fee = $this->invoice->amount - $invoice_total;
|
$fee = $this->invoice->balance - $invoice_total;
|
||||||
else
|
else
|
||||||
$fee = $this->invoice->amount - $amount;
|
$fee = $this->invoice->balance - $amount;
|
||||||
|
|
||||||
|
if($fee > $amount)
|
||||||
|
$fee = 0;
|
||||||
|
|
||||||
/* Build payment hash */
|
/* Build payment hash */
|
||||||
$payment_hash = PaymentHash::create([
|
$payment_hash = PaymentHash::create([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user