mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on gateway fees
This commit is contained in:
parent
8a90d46287
commit
c7512f1572
29
app/DataMapper/PaymentTransaction.php
Normal file
29
app/DataMapper/PaymentTransaction.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\DataMapper;
|
||||
|
||||
class PaymentTransaction
|
||||
{
|
||||
|
||||
public $transaction_id;
|
||||
|
||||
public $gateway_response;
|
||||
|
||||
public $account_gateway_id;
|
||||
|
||||
public $payment_type_id;
|
||||
|
||||
public $status; // prepayment|payment|response|completed
|
||||
|
||||
public $invoices;
|
||||
|
||||
}
|
@ -183,10 +183,22 @@ class Client extends BaseModel
|
||||
$payment_methods_collections = collect($payment_methods);
|
||||
$payment_methods_intersect = $payment_methods_collections->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,
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 = '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user