Powerboard

This commit is contained in:
David Bomba 2024-09-06 18:31:00 +10:00
parent 54c1831228
commit 454f7df01e
6 changed files with 173 additions and 24 deletions

View File

@ -50,7 +50,7 @@ class InvoiceSummary extends Component
public function downloadDocument($invoice_hashed_id)
{
nlog("here");
$contact = $this->getContext()['contact'];
$_invoices = $this->getContext()['invoices'];
$i = $_invoices->first(function ($i) use($invoice_hashed_id){
@ -61,11 +61,6 @@ class InvoiceSummary extends Component
$file = (new \App\Jobs\Entity\CreateRawPdf($i->invitations()->where('client_contact_id', $contact->id)->first()))->handle();
nlog("here");
nlog($file);
$headers = ['Content-Type' => 'application/pdf'];
return response()->streamDownload(function () use ($file) {

View File

@ -237,8 +237,8 @@ class Gateway extends StaticModel
]; // Rotessa
case 64: //b67581d804dbad1743b61c57285142ad - powerboard
return [
]
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
];
default:
return [];
}

View File

@ -56,7 +56,10 @@ class CreditCard implements LivewireMethodInterface
{
// $description = $this->stripe->getDescription(false);
$merge = [
'publicKey' => $this->powerboard->company_gateway->getConfigField('publicKey'),
'public_key' => $this->powerboard->company_gateway->getConfigField('publicKey'),
'widget_endpoint' => $this->powerboard->widget_endpoint,
'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()),
@ -81,7 +84,7 @@ class CreditCard implements LivewireMethodInterface
{
$data = $this->paymentData($data);
return render('gateways.stripe.credit_card.pay', $data);
return render('gateways.powerboard.credit_card.pay', $data);
}
public function livewirePaymentView(array $data): string
@ -91,6 +94,8 @@ class CreditCard implements LivewireMethodInterface
public function paymentResponse(PaymentResponseRequest $request)
{
nlog($request->all());
// $this->stripe->init();
// $state = [

View File

@ -37,9 +37,11 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
public $refundable = true;
protected $api_endpoint = 'https://api.powerboard.commbank.com.au/';
public string $api_endpoint = 'https://api.powerboard.commbank.com.au/';
protected $widget_endpoint = 'https://widget.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js';
public string $widget_endpoint = 'https://widget.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js';
public string $environment = 'production_cba';
public static $methods = [
GatewayType::CREDIT_CARD => CreditCard::class,
@ -60,14 +62,19 @@ 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';
}
return $this;
}
public function setPaymentMethod($payment_method_id)
{
$this->payment_method = $payment_method_id;
$class = self::$methods[$payment_method_id];
$this->payment_method = new $class($this);
return $this;
}
@ -80,6 +87,8 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
*/
public function processPaymentView($data)
{
$this->init();
return $this->payment_method->paymentView($data);
}

View File

@ -0,0 +1,150 @@
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Credit card', 'card_title' => 'Credit card'])
@section('gateway_head')
<meta name="instant-payment" content="yes" />
@endsection
@section('gateway_content')
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
<input type="hidden" name="gateway_response">
<input type="hidden" name="store_card" id="store_card"/>
<input type="hidden" name="payment_hash" value="{{ $payment_hash }}">
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="token">
<button type="submit" class="hidden" id="stub">Submit</button>
</form>
<div class="alert alert-failure mb-4" hidden id="errors"></div>
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')])
{{ ctrans('texts.credit_card') }}
@endcomponent
@include('portal.ninja2020.gateways.includes.payment_details')
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')])
<ul class="list-none">
@if(count($tokens) > 0)
@foreach($tokens as $token)
<li class="py-2 cursor-pointer">
<label class="mr-4">
<input
type="radio"
data-token="{{ $token->token }}"
name="payment-type"
class="form-check-input text-indigo-600 rounded-full cursor-pointer toggle-payment-with-token toggle-payment-with-token"/>
<span class="ml-1 cursor-pointer">**** {{ $token->meta?->last4 }}</span>
</label>
</li>
@endforeach
@endisset
<li class="py-2 cursor-pointer">
<label>
<input
type="radio"
id="toggle-payment-with-credit-card"
class="form-check-input text-indigo-600 rounded-full cursor-pointer"
name="payment-type"
checked/>
<span class="ml-1 cursor-pointer">{{ __('texts.new_card') }}</span>
</label>
</li>
</ul>
@endcomponent
<div id="powerboard-payment-container" class="w-full">
<div id="widget" style="block"></div>
</div>
@include('portal.ninja2020.gateways.includes.pay_now')
@endsection
@section('gateway_footer')
<style>
iframe {
border: 0;
width: 100%;
height: 400px;
}
</style>
<script src="{{ $widget_endpoint }}"></script>
<script>
var widget = new cba.HtmlWidget('#widget', '{{ $public_key }}', 'not_configured');
widget.setEnv("{{ $environment }}");
widget.useAutoResize();
widget.interceptSubmitForm('#server-response');
widget.onFinishInsert('input[name="gateway_response"]', "payment_source");
widget.load();
widget.on("systemError", function(data) {
console.log("Widget Response", data);
// document.querySelector(
// 'input[name="gateway_response"]'
// ).value = JSON.stringify(data);
});
widget.on("validationError", function(data) {
console.log("Widget Response", data);
// document.querySelector(
// 'input[name="gateway_response"]'
// ).value = JSON.stringify(data);
});
widget.on("finish", function(data) {
console.log("Widget Response", data);
// document.querySelector(
// 'input[name="gateway_response"]'
// ).value = JSON.stringify(data);
});
widget.on('form_submit', function (data) {
console.log(data);
});
widget.on('submit', function (data) {
console.log(data);
});
let payNow = document.getElementById('pay-now');
payNow.addEventListener('click', () => {
widget.getValidationState();
if(!widget.isValidForm()){
console.log("invalid");
return;
}
// // payNow.disabled = true;
// // payNow.querySelector('svg').classList.remove('hidden');
// // payNow.querySelector('span').classList.add('hidden');
//
document.getElementById('stub').click();
});
</script>
@endsection

View File

@ -1,10 +0,0 @@
<script src="https://widget.preproduction.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js"></script>
<script>
var widget = new cba.HtmlWidget('#widget', 'PUBLIC_KEY', 'GATEWAY_ID');
widget.setEnv("preproduction_cba");
widget.load();
</script>
<div id="widget"></div>