diff --git a/app/PaymentDrivers/WePay/ACH.php b/app/PaymentDrivers/WePay/ACH.php index a8c00ccb8570..1060ee5c04ad 100644 --- a/app/PaymentDrivers/WePay/ACH.php +++ b/app/PaymentDrivers/WePay/ACH.php @@ -197,14 +197,20 @@ class ACH if($token_meta->state != "authorized") return redirect()->route('client.payment_methods.verification', ['payment_method' => $token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]); + $app_fee = (config('ninja.wepay.fee_ach_multiplier') * $this->wepay_payment_driver->payment_hash->data->amount_with_fee) + config('ninja.wepay.fee_fixed'); + $response = $this->wepay_payment_driver->wepay->request('checkout/create', array( // 'callback_uri' => route('payment_webhook', ['company_key' => $this->wepay_payment_driver->company_gateway->company->company_key, 'company_gateway_id' => $this->wepay_payment_driver->company_gateway->hashed_id]), 'unique_id' => Str::random(40), 'account_id' => $this->wepay_payment_driver->company_gateway->getConfigField('accountId'), 'amount' => $this->wepay_payment_driver->payment_hash->data->amount_with_fee, 'currency' => $this->wepay_payment_driver->client->getCurrencyCode(), - 'short_description' => 'A vacation home rental', + 'short_description' => 'Goods and Services', 'type' => 'goods', + 'fee' => [ + 'fee_payer' => config('ninja.wepay.fee_payer'), + 'app_fee' => $app_fee, + ], 'payment_method' => array( 'type' => 'payment_bank', 'payment_bank' => array( diff --git a/app/PaymentDrivers/WePay/CreditCard.php b/app/PaymentDrivers/WePay/CreditCard.php index 9fa7b0ac0f24..a943800e4a28 100644 --- a/app/PaymentDrivers/WePay/CreditCard.php +++ b/app/PaymentDrivers/WePay/CreditCard.php @@ -139,16 +139,21 @@ use WePayCommon; } // USD, CAD, and GBP. - nlog($request->all()); + // nlog($request->all()); + + $app_fee = (config('ninja.wepay.fee_cc_multiplier') * $this->wepay_payment_driver->payment_hash->data->amount_with_fee) + config('ninja.wepay.fee_fixed'); // charge the credit card $response = $this->wepay_payment_driver->wepay->request('checkout/create', array( - // 'callback_uri' => route('payment_webhook', ['company_key' => $this->wepay_payment_driver->company_gateway->company->company_key, 'company_gateway_id' => $this->wepay_payment_driver->company_gateway->hashed_id]), 'unique_id' => Str::random(40), 'account_id' => $this->wepay_payment_driver->company_gateway->getConfigField('accountId'), 'amount' => $this->wepay_payment_driver->payment_hash->data->amount_with_fee, 'currency' => $this->wepay_payment_driver->client->getCurrencyCode(), - 'short_description' => 'A vacation home rental', + 'short_description' => 'Goods and services', 'type' => 'goods', + 'fee' => [ + 'fee_payer' => config('ninja.wepay.fee_payer'), + 'app_fee' => $app_fee, + ], 'payment_method' => array( 'type' => 'credit_card', 'credit_card' => array( diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index acffce11362b..d1af97ac61cd 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -266,18 +266,17 @@ class WePayPaymentDriver extends BaseDriver $response = $this->wepay->request('checkout/refund', array( 'checkout_id' => $payment->transaction_reference, - 'refund_reason' => 'Refund', + 'refund_reason' => 'Refund by merchant', 'amount' => $amount )); - - return [ - 'transaction_reference' => $response->checkout_id, - 'transaction_response' => json_encode($response), - 'success' => $response->state == 'refunded' ? true : false, - 'description' => 'refund', - 'code' => 0, - ]; + return [ + 'transaction_reference' => $response->checkout_id, + 'transaction_response' => json_encode($response), + 'success' => $response->state == 'refunded' ? true : false, + 'description' => 'refund', + 'code' => 0, + ]; } diff --git a/config/ninja.php b/config/ninja.php index 693978986101..5d0fe8d5ac8c 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -152,6 +152,10 @@ return [ 'environment' => env('WEPAY_ENVIRONMENT', 'stage'), 'client_id' => env('WEPAY_CLIENT_ID', ''), 'client_secret' => env('WEPAY_CLIENT_SECRET',''), + 'fee_payer' => env('WEPAY_FEE_PAYER'), + 'fee_cc_multiplier' => env('WEPAY_APP_FEE_CC_MULTIPLIER'), + 'fee_ach_multiplier' => env('WEPAY_APP_FEE_ACH_MULTIPLIER'), + 'fee_fixed' => env('WEPAY_APP_FEE_FIXED'), ], 'ninja_stripe_publishable_key' => env('NINJA_PUBLISHABLE_KEY', null), 'ninja_stripe_client_id' => env('NINJA_STRIPE_CLIENT_ID', null),