diff --git a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php index f8ef176e991a..fb2e8e14329e 100644 --- a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php +++ b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php @@ -30,18 +30,27 @@ class CreditCard implements LivewireMethodInterface public function authorizeView(array $data) { - $intent['intent'] = $this->stripe->getSetupIntent(); - return render('gateways.powerboard.credit_card.authorize', array_merge($data, $intent)); + return render('gateways.powerboard.credit_card.authorize', array_merge($data, [])); } public function authorizeResponse($request) { - $this->stripe->init(); + $this->powerboard->init(); + + $payment_source = $request->gateway_response; + + $payload = [ + 'token' => $payment_source, + + ]; + + $this->powerboard->gatewayRequest('/v1/vault/payment_sources', 'post', $payload, []); + // $stripe_response = json_decode($request->input('gateway_response')); - $customer = $this->powerboard->findOrCreateCustomer(); + // $customer = $this->powerboard->findOrCreateCustomer(); // $this->stripe->attach($stripe_response->payment_method, $customer); @@ -61,22 +70,8 @@ class CreditCard implements LivewireMethodInterface 'gateway' => $this->powerboard, 'environment' => $this->powerboard->environment, ]; - // $payment_intent_data = [ - // 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - // 'currency' => $this->stripe->client->getCurrencyCode(), - // 'customer' => $this->stripe->findOrCreateCustomer(), - // 'description' => $description, - // 'metadata' => [ - // 'payment_hash' => $this->stripe->payment_hash->hash, - // 'gateway_type_id' => GatewayType::CREDIT_CARD, - // ], - // 'setup_future_usage' => 'off_session', - // 'payment_method_types' => ['card'], - // ]; - - // $data['intent'] = $this->stripe->createPaymentIntent($payment_intent_data); - // $data['gateway'] = $this->stripe; + return array_merge($data, $merge); } @@ -95,7 +90,7 @@ class CreditCard implements LivewireMethodInterface public function paymentResponse(PaymentResponseRequest $request) { nlog($request->all()); - + // $this->stripe->init(); // $state = [ diff --git a/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php b/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php index a14c294b117a..6e005e6d3bfd 100644 --- a/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php +++ b/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php @@ -37,7 +37,7 @@ class CBAPowerBoardPaymentDriver extends BaseDriver public $refundable = true; - public string $api_endpoint = 'https://api.powerboard.commbank.com.au/'; + public string $api_endpoint = 'https://api.powerboard.commbank.com.au'; public string $widget_endpoint = 'https://widget.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js'; @@ -62,7 +62,7 @@ class CBAPowerBoardPaymentDriver extends BaseDriver { if($this->company_gateway->getConfigField('testMode')) { $this->widget_endpoint = 'https://widget.preproduction.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js'; - $this->api_endpoint = 'https://api.preproduction.powerboard.commbank.com.au/'; + $this->api_endpoint = 'https://api.preproduction.powerboard.commbank.com.au'; $this->environment = 'preproduction_cba'; } @@ -151,4 +151,20 @@ class CBAPowerBoardPaymentDriver extends BaseDriver // return false; } + + public function gatewayRequest(string $uri, string $verb, array $payload, array $headers = []) + { + $r = Http::withHeaders($this->getHeaders($headers)) + ->{$verb}($this->api_endpoint.$uri, $payload); + } + + public function getHeaders(array $headers = []): array + { + return array_merge([ + 'x-user-secret-key' => $this->company_gateway->getConfigField('secretKey'), + 'Content-Type' => 'application/json', + ], + $headers); + } + }