From c7512f1572d30960c09ccaf0c7deab38baf1cd0a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 9 Sep 2019 13:27:16 +1000 Subject: [PATCH] Working on gateway fees --- app/DataMapper/PaymentTransaction.php | 29 +++++++++++++++++++++++++++ app/Models/Client.php | 18 ++++++++++++++--- app/Models/CompanyGateway.php | 15 ++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 app/DataMapper/PaymentTransaction.php diff --git a/app/DataMapper/PaymentTransaction.php b/app/DataMapper/PaymentTransaction.php new file mode 100644 index 0000000000..8097902e31 --- /dev/null +++ b/app/DataMapper/PaymentTransaction.php @@ -0,0 +1,29 @@ +intersectByKeys( $payment_methods_collections->flatten(1)->unique() ); - $multiplied = $collection->map(function ($item, $key) { - return $item * 2; + $payment_list = $payment_methods_intersect->map(function ($value, $key) { + + $gateway = $gateways->where('id', $key)->first(); + + $fee_label = $gateway->calcGatewayFee($amount, $this); + + return [ + 'company_gateway_id' => $key, + 'payment_method_id' => $value, + 'url' => $label + 'label' => ctrans('texts.'$gateway->type->alias) . $fee_label, + ]; + }); - + + } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 1ba12aa235..891fac8a7f 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -127,4 +127,19 @@ class CompanyGateway extends BaseModel { return ! empty($this->config('enablePayPal')); } + + /** + * Returns the formatted fee amount for the gateway + * + * @param float $amount The payment amount + * @param Client $client The client object + * @return string The fee amount formatted in the client currency + */ + public function calcGatewayFee($amount, Client $client) :string + { + + $fee = ''; + + } + }