PayPal: Update amount with fee

This commit is contained in:
Benjamin Beganović 2020-12-21 12:10:47 +01:00
parent 0b95e8c8bc
commit f6758873e7

View File

@ -88,7 +88,7 @@ class PayPalExpressPaymentDriver extends BaseDriver
$this->initializeOmnipayGateway(); $this->initializeOmnipayGateway();
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['amount_with_fee']]); $this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['amount_with_fee']]);
$this->payment_hash->save(); $this->payment_hash->save();
$response = $this->omnipay_gateway $response = $this->omnipay_gateway
@ -100,7 +100,7 @@ class PayPalExpressPaymentDriver extends BaseDriver
return $response->redirect(); return $response->redirect();
} }
PaymentFailureMailer::dispatch($this->client, $response->getData(), $this->client->company, $data['amount_with_fee']); PaymentFailureMailer::dispatch($this->client, $response->getData(), $this->client->company, $data['total']['amount_with_fee']);
$message = [ $message = [
'server_response' => $response->getMessage(), 'server_response' => $response->getMessage(),
@ -183,7 +183,7 @@ class PayPalExpressPaymentDriver extends BaseDriver
'currency' => $this->client->getCurrencyCode(), 'currency' => $this->client->getCurrencyCode(),
'transactionType' => 'Purchase', 'transactionType' => 'Purchase',
'clientIp' => request()->getClientIp(), 'clientIp' => request()->getClientIp(),
'amount' => $data['amount_with_fee'], 'amount' => $data['total']['amount_with_fee'],
'returnUrl' => route('client.payments.response', [ 'returnUrl' => route('client.payments.response', [
'company_gateway_id' => $this->company_gateway->id, 'company_gateway_id' => $this->company_gateway->id,
'payment_hash' => $this->payment_hash->hash, 'payment_hash' => $this->payment_hash->hash,
@ -223,11 +223,11 @@ class PayPalExpressPaymentDriver extends BaseDriver
}); });
}); });
if ($total != $data['amount_with_fee']) { if ($total != $data['total']['amount_with_fee']) {
$items[0][] = new Item([ $items[0][] = new Item([
'name' => trans('texts.taxes_and_fees'), 'name' => trans('texts.taxes_and_fees'),
'description' => '', 'description' => '',
'price' => $data['amount_with_fee'] - $total, 'price' => $data['total']['amount_with_fee'] - $total,
'quantity' => 1, 'quantity' => 1,
]); ]);
} }