Updates for paypal rest

This commit is contained in:
David Bomba 2023-07-23 09:32:05 +10:00
parent 7853257234
commit 8aa8d6521c
3 changed files with 41 additions and 44 deletions

View File

@ -195,13 +195,13 @@ class Gateway extends StaticModel
GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false], GatewayType::PAYPAL => ['refund' => false, 'token_billing' => false],
GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false], GatewayType::CREDIT_CARD => ['refund' => false, 'token_billing' => false],
GatewayType::VENMO => ['refund' => false, 'token_billing' => false], GatewayType::VENMO => ['refund' => false, 'token_billing' => false],
GatewayType::SEPA => ['refund' => false, 'token_billing' => false], // GatewayType::SEPA => ['refund' => false, 'token_billing' => false],
GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false], // GatewayType::BANCONTACT => ['refund' => false, 'token_billing' => false],
GatewayType::EPS => ['refund' => false, 'token_billing' => false], // GatewayType::EPS => ['refund' => false, 'token_billing' => false],
GatewayType::MYBANK => ['refund' => false, 'token_billing' => false], // GatewayType::MYBANK => ['refund' => false, 'token_billing' => false],
GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false], // GatewayType::PAYLATER => ['refund' => false, 'token_billing' => false],
GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false], // GatewayType::PRZELEWY24 => ['refund' => false, 'token_billing' => false],
GatewayType::SOFORT => ['refund' => false, 'token_billing' => false], // GatewayType::SOFORT => ['refund' => false, 'token_billing' => false],
]; //Paypal ]; //Paypal
default: default:

View File

@ -38,10 +38,9 @@ class PayPalRestPaymentDriver extends BaseDriver
private string $api_endpoint_url = ''; private string $api_endpoint_url = '';
public function gatewayTypes() private string $paypal_payment_method = '';
{
$enums = [ private array $funding_options = [
3 => 'paypal', 3 => 'paypal',
1 => 'card', 1 => 'card',
25 => 'venmo', 25 => 'venmo',
@ -57,6 +56,10 @@ class PayPalRestPaymentDriver extends BaseDriver
7 => 'sofort' 7 => 'sofort'
]; ];
public function gatewayTypes()
{
$funding_options = []; $funding_options = [];
foreach ($this->company_gateway->fees_and_limits as $key => $value) { foreach ($this->company_gateway->fees_and_limits as $key => $value) {
@ -67,10 +70,6 @@ class PayPalRestPaymentDriver extends BaseDriver
return $funding_options; return $funding_options;
// return [
// GatewayType::PAYPAL,
// ];
} }
public function init() public function init()
@ -88,6 +87,8 @@ class PayPalRestPaymentDriver extends BaseDriver
public function setPaymentMethod($payment_method_id) public function setPaymentMethod($payment_method_id)
{ {
$this->paypal_payment_method = $this->funding_options[$payment_method_id];
return $this; return $this;
} }
@ -117,7 +118,7 @@ class PayPalRestPaymentDriver extends BaseDriver
$data['client_id'] = $this->company_gateway->getConfigField('clientId'); $data['client_id'] = $this->company_gateway->getConfigField('clientId');
$data['token'] = $this->getClientToken(); $data['token'] = $this->getClientToken();
$data['order_id'] = $this->createOrder($data); $data['order_id'] = $this->createOrder($data);
$data['funding_options'] = $this->getFundingOptions(); $data['funding_options'] = $this->paypal_payment_method;
return render('gateways.paypal.pay', $data); return render('gateways.paypal.pay', $data);
@ -130,16 +131,16 @@ class PayPalRestPaymentDriver extends BaseDriver
3 => 'paypal', 3 => 'paypal',
1 => 'card', 1 => 'card',
25 => 'venmo', 25 => 'venmo',
9 => 'sepa', // 9 => 'sepa',
12 => 'bancontact', // 12 => 'bancontact',
17 => 'eps', // 17 => 'eps',
15 => 'giropay', // 15 => 'giropay',
13 => 'ideal', // 13 => 'ideal',
26 => 'mercadopago', // 26 => 'mercadopago',
27 => 'mybank', // 27 => 'mybank',
28 => 'paylater', // 28 => 'paylater',
16 => 'p24', // 16 => 'p24',
7 => 'sofort' // 7 => 'sofort'
]; ];
$funding_options = ''; $funding_options = '';
@ -231,10 +232,6 @@ class PayPalRestPaymentDriver extends BaseDriver
[ [
"description" =>ctrans('texts.invoice_number').'# '.$invoice->number, "description" =>ctrans('texts.invoice_number').'# '.$invoice->number,
"invoice_id" => $invoice->number, "invoice_id" => $invoice->number,
// 'reference_id' => 'PUHF',
// 'description' => 'Sporting Goods',
// 'custom_id' => 'CUST-HighFashions',
// 'soft_descriptor' => 'HighFashions',
"amount" => [ "amount" => [
"value" => (string)$data['amount_with_fee'], "value" => (string)$data['amount_with_fee'],
"currency_code"=> $this->client->currency()->code, "currency_code"=> $this->client->currency()->code,

View File

@ -28,7 +28,7 @@
@endsection @endsection
@push('footer') @push('footer')
<script src="https://www.paypal.com/sdk/js?buyer-country=DE&currency=EUR&enable-funding={$funding_options}&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}" data-client-token="{!! $token !!}"> <script src="https://www.paypal.com/sdk/js?buyer-country=US&currency=USD&enable-funding={!! $funding_options !!}&disable-funding=credit&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}" data-client-token="{!! $token !!}">
</script> </script>
<script> <script>