Add level 2 meta data for Braintree payment gateway
This commit is contained in:
parent
a3e27e8550
commit
12702b1ff3
|
|
@ -140,6 +140,10 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
|||
->where('id', $this->decodePrimaryKey($request->source))
|
||||
->firstOrFail();
|
||||
|
||||
$total_taxes = \App\Models\Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->braintree->payment_hash->invoices(), 'invoice_id')))->withTrashed()->sum('total_taxes');
|
||||
$invoice = $this->braintree->payment_hash->fee_invoice;
|
||||
$po_number = $invoice->po_number ?? $invoice->number ?? '';
|
||||
|
||||
$result = $this->braintree->gateway->transaction()->sale([
|
||||
'amount' => $this->braintree->payment_hash->data->amount_with_fee,
|
||||
'paymentMethodToken' => $token->token,
|
||||
|
|
@ -147,6 +151,8 @@ class ACH implements MethodInterface, LivewireMethodInterface
|
|||
'options' => [
|
||||
'submitForSettlement' => true,
|
||||
],
|
||||
'tax_amount' => $total_taxes,
|
||||
'purchase_order_number' => $po_number,
|
||||
]);
|
||||
|
||||
if ($result->success) {
|
||||
|
|
|
|||
|
|
@ -12,19 +12,21 @@
|
|||
|
||||
namespace App\PaymentDrivers\Braintree;
|
||||
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Models\Payment;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentType;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\PaymentDrivers\BraintreePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
|
||||
class CreditCard implements LivewireMethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
/**
|
||||
* @var BraintreePaymentDriver
|
||||
*/
|
||||
|
|
@ -108,6 +110,10 @@ class CreditCard implements LivewireMethodInterface
|
|||
|
||||
$token = $this->getPaymentToken($request->all(), $customer->id);
|
||||
|
||||
$total_taxes = \App\Models\Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->braintree->payment_hash->invoices(), 'invoice_id')))->withTrashed()->sum('total_taxes');
|
||||
$invoice = $this->braintree->payment_hash->fee_invoice;
|
||||
$po_number = $invoice->po_number ?? $invoice->number ?? '';
|
||||
|
||||
$data = [
|
||||
'amount' => $this->braintree->payment_hash->data->amount_with_fee, //@phpstan-ignore-line
|
||||
'paymentMethodToken' => $token,
|
||||
|
|
@ -122,7 +128,9 @@ class CreditCard implements LivewireMethodInterface
|
|||
'locality' => $this->braintree->client->city ?: '',
|
||||
'postalCode' => $this->braintree->client->postal_code ?: '',
|
||||
'countryCodeAlpha2' => $this->braintree->client->country ? $this->braintree->client->country->iso_3166_2 : 'US',
|
||||
]
|
||||
],
|
||||
'tax_amount' => $total_taxes,
|
||||
'purchase_order_number' => $po_number,
|
||||
];
|
||||
|
||||
if ($this->braintree->company_gateway->getConfigField('merchantAccountId')) {
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ use App\Models\PaymentType;
|
|||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\BraintreePaymentDriver;
|
||||
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class PayPal implements LivewireMethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
/**
|
||||
* @var BraintreePaymentDriver
|
||||
*/
|
||||
|
|
@ -68,6 +70,10 @@ class PayPal implements LivewireMethodInterface
|
|||
|
||||
$token = $this->getPaymentToken($request->all(), $customer->id);
|
||||
|
||||
$total_taxes = \App\Models\Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->braintree->payment_hash->invoices(), 'invoice_id')))->withTrashed()->sum('total_taxes');
|
||||
$invoice = $this->braintree->payment_hash->fee_invoice;
|
||||
$po_number = $invoice->po_number ?? $invoice->number ?? '';
|
||||
|
||||
$result = $this->braintree->gateway->transaction()->sale([
|
||||
'amount' => $this->braintree->payment_hash->data->amount_with_fee,
|
||||
'paymentMethodToken' => $token,
|
||||
|
|
@ -79,6 +85,8 @@ class PayPal implements LivewireMethodInterface
|
|||
'description' => 'Meaningful description.',
|
||||
],
|
||||
],
|
||||
'tax_amount' => $total_taxes,
|
||||
'purchase_order_number' => $po_number,
|
||||
]);
|
||||
|
||||
if ($result->success) {
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ class BraintreePaymentDriver extends BaseDriver
|
|||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||
|
||||
$invoice = Invoice::query()->whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->first();
|
||||
$total_taxes = Invoice::query()->whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->sum('total_taxes');
|
||||
|
||||
if ($invoice) {
|
||||
$description = "Invoice {$invoice->number} for {$amount} for client {$this->client->present()->name()}";
|
||||
|
|
@ -235,9 +236,12 @@ class BraintreePaymentDriver extends BaseDriver
|
|||
'amount' => $amount,
|
||||
'paymentMethodToken' => $cgt->token,
|
||||
'deviceData' => '',
|
||||
'channel' => 'invoiceninja_BT',
|
||||
'options' => [
|
||||
'submitForSettlement' => true,
|
||||
],
|
||||
'tax_amount' => $total_taxes,
|
||||
'purchase_order_number' => $invoice->po_number ?? $invoice->number,
|
||||
]);
|
||||
|
||||
if ($result->success) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue