update credentials to call through Invoice Ninja

This commit is contained in:
David Bomba 2023-10-29 20:09:15 +11:00
parent 255c58fd3b
commit 5af0195abf
3 changed files with 8 additions and 7 deletions

View File

@ -142,9 +142,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver
$this->api_endpoint_url = $this->company_gateway->getConfigField('testMode') ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com'; $this->api_endpoint_url = $this->company_gateway->getConfigField('testMode') ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
$secret = $this->company_gateway->getConfigField('secret'); $secret = config('ninja.paypal.secret');
$client_id = config('ninja.paypal.client_id');
$client_id = $this->company_gateway->getConfigField('clientId');
if($this->access_token && $this->token_expiry && $this->token_expiry->isFuture()) if($this->access_token && $this->token_expiry && $this->token_expiry->isFuture())
return $this; return $this;
@ -154,6 +153,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver
->withQueryParameters(['grant_type' => 'client_credentials']) ->withQueryParameters(['grant_type' => 'client_credentials'])
->post("{$this->api_endpoint_url}/v1/oauth2/token"); ->post("{$this->api_endpoint_url}/v1/oauth2/token");
nlog($response->body());
if($response->successful()) { if($response->successful()) {
$this->access_token = $response->json()['access_token']; $this->access_token = $response->json()['access_token'];
$this->token_expiry = now()->addSeconds($response->json()['expires_in'] - 60); $this->token_expiry = now()->addSeconds($response->json()['expires_in'] - 60);
@ -200,7 +201,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
$this->payment_hash->data = array_merge((array) $this->payment_hash->data, ['amount' => $data['total']['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();
$data['client_id'] = $this->company_gateway->getConfigField('clientId'); $data['client_id'] = config('ninja.paypal.client_id');
$data['token'] = $this->getClientToken(); $data['token'] = $this->getClientToken();
$data['order_id'] = $this->createOrder($data); $data['order_id'] = $this->createOrder($data);
$data['funding_source'] = $this->paypal_payment_method; $data['funding_source'] = $this->paypal_payment_method;
@ -367,7 +368,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
'Content-type' => 'application/json', 'Content-type' => 'application/json',
'Accept-Language' => 'en_US', 'Accept-Language' => 'en_US',
'PayPal-Partner-Attribution-Id' => 'invoiceninja_SP_PPCP', 'PayPal-Partner-Attribution-Id' => 'invoiceninja_SP_PPCP',
'PayPal-Request-Id' => Str::uuid(), 'PayPal-Request-Id' => Str::uuid()->toString(),
], $headers); ], $headers);
} }

View File

@ -84,7 +84,7 @@ class PaymentLibrariesSeeder extends Seeder
['id' => 58, 'name' => 'Razorpay', 'provider' => 'Razorpay', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9', 'fields' => '{"apiKey":"","apiSecret":""}'], ['id' => 58, 'name' => 'Razorpay', 'provider' => 'Razorpay', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9', 'fields' => '{"apiKey":"","apiSecret":""}'],
['id' => 59, 'name' => 'Forte', 'provider' => 'Forte', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs', 'fields' => '{"testMode":false,"apiLoginId":"","apiAccessId":"","secureKey":"","authOrganizationId":"","organizationId":"","locationId":""}'], ['id' => 59, 'name' => 'Forte', 'provider' => 'Forte', 'is_offsite' => false, 'sort_order' => 21, 'key' => 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs', 'fields' => '{"testMode":false,"apiLoginId":"","apiAccessId":"","secureKey":"","authOrganizationId":"","organizationId":"","locationId":""}'],
['id' => 60, 'name' => 'PayPal REST', 'provider' => 'PayPal_Rest', 'key' => '80af24a6a691230bbec33e930ab40665', 'fields' => '{"clientId":"","secret":"","signature":"","testMode":false}'], ['id' => 60, 'name' => 'PayPal REST', 'provider' => 'PayPal_Rest', 'key' => '80af24a6a691230bbec33e930ab40665', 'fields' => '{"clientId":"","secret":"","signature":"","testMode":false}'],
['id' => 61, 'name' => 'PayPal Platform', 'provider' => 'PayPal_PPCP', 'key' => '80af24a6a691230bbec33e930ab40666', 'fields' => '{"clientId":"","secret":"","signature":"","testMode":false}'], ['id' => 61, 'name' => 'PayPal Platform', 'provider' => 'PayPal_PPCP', 'key' => '80af24a6a691230bbec33e930ab40666', 'fields' => '{"testMode":false}'],
]; ];
foreach ($gateways as $gateway) { foreach ($gateways as $gateway) {

View File

@ -37,7 +37,7 @@
//&buyer-country=US&currency=USD&enable-funding=venmo //&buyer-country=US&currency=USD&enable-funding=venmo
const fundingSource = "{!! $funding_source !!}"; const fundingSource = "{!! $funding_source !!}";
const testMode = {{ $gateway->company_gateway->getConfigField('testMode') }}; const testMode = {{ $gateway->company_gateway->getConfigField('testMode') }};
const clientId = "{{ $gateway->company_gateway->getConfigField('clientId') }}"; const clientId = "{{ $client_id }}";
const sandbox = { sandbox: clientId }; const sandbox = { sandbox: clientId };
const production = { production: clientId }; const production = { production: clientId };
const orderId = "{!! $order_id !!}"; const orderId = "{!! $order_id !!}";