mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Testing powerboard
This commit is contained in:
parent
b715c7dd20
commit
4f46fa1029
@ -40,7 +40,8 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
{
|
{
|
||||||
$data['payment_method_id'] = GatewayType::CREDIT_CARD;
|
$data['payment_method_id'] = GatewayType::CREDIT_CARD;
|
||||||
|
|
||||||
return render('gateways.powerboard.credit_card.authorize', $this->paymentData($data));
|
$view = $this->powerboard->company_gateway->getConfigField('threeds') ? 'gateways.powerboard.credit_card.authorize' : 'gateways.powerboard.credit_card.authorize_no_3ds';
|
||||||
|
return render($view, $this->paymentData($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorizeResponse($request)
|
public function authorizeResponse($request)
|
||||||
@ -136,8 +137,28 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elseif($request->charge_no3d){
|
||||||
|
nlog($request->all());
|
||||||
|
|
||||||
|
$payment_source = $this->storePaymentSource($request);
|
||||||
|
|
||||||
// $cgt = $this->powerboard->customer()->storePaymentMethod($request);
|
nlog($payment_source);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
"payment_source" => [
|
||||||
|
"vault_token" => $payment_source->vault_token,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$customer = $this->powerboard->customer()->findOrCreateCustomer($data);
|
||||||
|
|
||||||
|
$cgt = $this->powerboard->customer()->storePaymentMethod($payment_source, $customer);
|
||||||
|
$cgt->gateway_customer_reference = $this->powerboard->settings()->getGatewayId(GatewayType::CREDIT_CARD);
|
||||||
|
$cgt->save();
|
||||||
|
|
||||||
|
return redirect()->route('client.payment_methods.show', ['payment_method' => $cgt->hashed_id]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->route('client.payment_methods.index');
|
return redirect()->route('client.payment_methods.index');
|
||||||
|
|
||||||
@ -176,6 +197,8 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
'store_ccv' => true,
|
'store_ccv' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
nlog($payload);
|
||||||
|
|
||||||
$r = $this->powerboard->gatewayRequest('/v1/vault/payment_sources', (\App\Enum\HttpVerb::POST)->value, $payload, []);
|
$r = $this->powerboard->gatewayRequest('/v1/vault/payment_sources', (\App\Enum\HttpVerb::POST)->value, $payload, []);
|
||||||
|
|
||||||
if($r->failed())
|
if($r->failed())
|
||||||
@ -236,8 +259,13 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
|
|
||||||
nlog($r->body());
|
nlog($r->body());
|
||||||
|
|
||||||
if($r->failed())
|
if($r->failed()){
|
||||||
return $this->processUnsuccessfulPayment($r);
|
// return $this->processUnsuccessfulPayment($r);
|
||||||
|
|
||||||
|
$error_payload = $this->getErrorFromResponse($r);
|
||||||
|
throw new PaymentFailed($error_payload[0], $error_payload[1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$charge = (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(Charge::class, $r->object()->resource->data) ?? $r->throw();
|
$charge = (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(Charge::class, $r->object()->resource->data) ?? $r->throw();
|
||||||
|
|
||||||
@ -414,9 +442,10 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
$error_message = "Unknown error";
|
$error_message = "Unknown error";
|
||||||
|
|
||||||
match($error_object->error->code) {
|
match($error_object->error->code) {
|
||||||
|
"GatewayError" => $error_message = $error_object->error->message,
|
||||||
"UnfulfilledCondition" => $error_message = $error_object->error->message,
|
"UnfulfilledCondition" => $error_message = $error_object->error->message,
|
||||||
"transaction_declined" => $error_message = $error_object->error->details[0]->status_code_description,
|
"transaction_declined" => $error_message = $error_object->error->details[0]->status_code_description,
|
||||||
default => $error_message = "Unknown error",
|
default => $error_message = $error_object->error->message ?? "Unknown error",
|
||||||
};
|
};
|
||||||
|
|
||||||
return [$error_message, $exception->getCode()];
|
return [$error_message, $exception->getCode()];
|
||||||
|
@ -56,9 +56,16 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
|
|||||||
*/
|
*/
|
||||||
public function gatewayTypes(): array
|
public function gatewayTypes(): array
|
||||||
{
|
{
|
||||||
$types = [
|
|
||||||
GatewayType::CREDIT_CARD,
|
$types = [];
|
||||||
];
|
|
||||||
|
if ($this->client
|
||||||
|
&& isset($this->client->country)
|
||||||
|
&& in_array($this->client->country->iso_3166_3, ['AUS'])
|
||||||
|
&& in_array($this->client->currency()->code, ['AUD'])
|
||||||
|
) {
|
||||||
|
$types[] = GatewayType::CREDIT_CARD;
|
||||||
|
}
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ return new class extends Migration
|
|||||||
$fields->publicKey = '';
|
$fields->publicKey = '';
|
||||||
$fields->secretKey = '';
|
$fields->secretKey = '';
|
||||||
$fields->testMode = false;
|
$fields->testMode = false;
|
||||||
$fields->Threeds = false;
|
$fields->threeds = false;
|
||||||
|
|
||||||
$powerboard = new Gateway();
|
$powerboard = new Gateway();
|
||||||
$powerboard->id = 64;
|
$powerboard->id = 64;
|
||||||
|
@ -0,0 +1,140 @@
|
|||||||
|
@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.payment_methods.store', ['method' => App\Models\GatewayType::CREDIT_CARD]) }}" method="post" id="server-response">
|
||||||
|
@csrf
|
||||||
|
<input type="hidden" name="gateway_response">
|
||||||
|
<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="charge_no3d">
|
||||||
|
<button type="submit" class="hidden" id="stub">Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="alert alert-failure mb-4" hidden id="errors"></div>
|
||||||
|
|
||||||
|
<div id="powerboard-payment-container" class="w-full">
|
||||||
|
<div id="widget" style="block"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-card'])
|
||||||
|
{{ ctrans('texts.add_payment_method') }}
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
@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 }}', '{{ $gateway_id }}');
|
||||||
|
widget.setEnv("{{ $environment }}");
|
||||||
|
widget.useAutoResize();
|
||||||
|
widget.interceptSubmitForm('#server-response');
|
||||||
|
widget.onFinishInsert('input[name="gateway_response"]', "payment_source");
|
||||||
|
widget.load();
|
||||||
|
|
||||||
|
widget.trigger('tab', function (data){
|
||||||
|
|
||||||
|
console.log("tab Response", data);
|
||||||
|
|
||||||
|
console.log(widget.isValidForm());
|
||||||
|
|
||||||
|
let payNow = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
payNow.disabled = widget.isInvalidForm();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.trigger('submit_form',function (data){
|
||||||
|
|
||||||
|
console.log("submit_form Response", data);
|
||||||
|
|
||||||
|
console.log(widget.isValidForm());
|
||||||
|
|
||||||
|
let payNow = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
payNow.disabled = widget.isInvalidForm();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.trigger('tab',function (data){
|
||||||
|
|
||||||
|
console.log("tab Response", data);
|
||||||
|
|
||||||
|
console.log(widget.isValidForm());
|
||||||
|
|
||||||
|
let payNow = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
payNow.disabled = widget.isInvalidForm();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on("systemError", function(data) {
|
||||||
|
console.log("systemError Response", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on("validationError", function(data) {
|
||||||
|
console.log("validationError", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on("finish", async function(data) {
|
||||||
|
document.getElementById('errors').hidden = true;
|
||||||
|
console.log("finish", data);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on("submit", async function (data){
|
||||||
|
console.log("submit");
|
||||||
|
console.log(data);
|
||||||
|
document.getElementById('errors').hidden = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
widget.on('form_submit', function (data) {
|
||||||
|
console.log("form_submit", data);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on('submit', function (data) {
|
||||||
|
console.log("submit", data);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.on('tab', function (data) {
|
||||||
|
console.log("tab", data);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
let payNow = document.getElementById('authorize-card');
|
||||||
|
|
||||||
|
payNow.addEventListener('click', () => {
|
||||||
|
|
||||||
|
document.querySelector(
|
||||||
|
'input[name="charge_no3d"]'
|
||||||
|
).value = true;
|
||||||
|
payNow.disabled = true;
|
||||||
|
payNow.querySelector('svg').classList.remove('hidden');
|
||||||
|
payNow.querySelector('span').classList.add('hidden');
|
||||||
|
|
||||||
|
document.getElementById('stub').click();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user