mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 11:14:31 -04:00
Powerboard
This commit is contained in:
parent
734878a73d
commit
67407103c7
@ -30,18 +30,20 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
|
|
||||||
public function authorizeView(array $data)
|
public function authorizeView(array $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
return render('gateways.powerboard.credit_card.authorize', $this->paymentData($data));
|
return render('gateways.powerboard.credit_card.authorize', $this->paymentData($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorizeResponse($request)
|
public function authorizeResponse($request)
|
||||||
{
|
{
|
||||||
$this->powerboard->init();
|
$cgt = $this->storePaymentMethod($request);
|
||||||
|
|
||||||
$payment_source = $request->gateway_response;
|
return redirect()->route('client.payment_methods.index');
|
||||||
|
|
||||||
$payload = [
|
}
|
||||||
'token' => $payment_source,
|
|
||||||
|
private function getCustomer(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
'first_name' => $this->powerboard->client->present()->first_name(),
|
'first_name' => $this->powerboard->client->present()->first_name(),
|
||||||
'last_name' => $this->powerboard->client->present()->first_name(),
|
'last_name' => $this->powerboard->client->present()->first_name(),
|
||||||
'email' => $this->powerboard->client->present()->email(),
|
'email' => $this->powerboard->client->present()->email(),
|
||||||
@ -53,12 +55,21 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
'address_country' => $this->powerboard->client->country->iso_3166_3 ?? '',
|
'address_country' => $this->powerboard->client->country->iso_3166_3 ?? '',
|
||||||
'address_city' => $this->powerboard->client->city ?? '',
|
'address_city' => $this->powerboard->client->city ?? '',
|
||||||
'address_postcode' => $this->powerboard->client->postal_code ?? '',
|
'address_postcode' => $this->powerboard->client->postal_code ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
private function storePaymentMethod($request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->powerboard->init();
|
||||||
|
|
||||||
|
$payment_source = $request->gateway_response;
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'token' => $payment_source,
|
||||||
'store_ccv' => true,
|
'store_ccv' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$r = $this->powerboard->gatewayRequest('/v1/vault/payment_sources', (\App\Enum\HttpVerb::POST)->value, array_merge($this->getCustomer(), $payload), []);
|
||||||
|
|
||||||
$r = $this->powerboard->gatewayRequest('/v1/vault/payment_sources', (\App\Enum\HttpVerb::POST)->value, $payload, []);
|
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// "status": 201,
|
// "status": 201,
|
||||||
@ -84,22 +95,11 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if($r->successful()){
|
|
||||||
|
|
||||||
$response_payload = $r->object();
|
|
||||||
|
|
||||||
$cgt = $this->storeGatewayToken($request, $response_payload);
|
|
||||||
|
|
||||||
return redirect()->route('client.payment_methods.index');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if($r->failed())
|
||||||
return $this->powerboard->processInternallyFailedPayment($this->powerboard, $r->throw());
|
return $this->powerboard->processInternallyFailedPayment($this->powerboard, $r->throw());
|
||||||
|
|
||||||
}
|
$response_payload = $r->object();
|
||||||
|
|
||||||
private function storeGatewayToken($request, $response_payload)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -116,7 +116,9 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
'payment_method_id' => $request->payment_method_id,
|
'payment_method_id' => $request->payment_method_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->powerboard->storeGatewayToken($data, ['gateway_customer_reference' => $response_payload->resource->data->ref_token]);
|
$cgt = $this->powerboard->storeGatewayToken($data, ['gateway_customer_reference' => $response_payload->resource->data->ref_token]);
|
||||||
|
|
||||||
|
return $cgt;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->powerboard->processInternallyFailedPayment($this->powerboard, $e);
|
return $this->powerboard->processInternallyFailedPayment($this->powerboard, $e);
|
||||||
@ -150,10 +152,39 @@ class CreditCard implements LivewireMethodInterface
|
|||||||
return 'gateways.powerboard.credit_card.pay_livewire';
|
return 'gateways.powerboard.credit_card.pay_livewire';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function tokenBilling($request, $cgt, $client_present = false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function paymentResponse(PaymentResponseRequest $request)
|
public function paymentResponse(PaymentResponseRequest $request)
|
||||||
{
|
{
|
||||||
nlog($request->all());
|
nlog($request->all());
|
||||||
|
|
||||||
|
if($request->store_card) {
|
||||||
|
$cgt = $this->storePaymentMethod($request);
|
||||||
|
$this->tokenBilling($request, $cgt, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'amount' => $this->powerboard->payment_hash->amount_with_fee(),
|
||||||
|
'currency' => $this->powerboard->client->currency()->code,
|
||||||
|
'description' => $this->powerboard->getDescription(),
|
||||||
|
// 'descriptor' => ,
|
||||||
|
// 'reference' => ,
|
||||||
|
// 'reference2' => ,
|
||||||
|
// 'amount_surcharge' => ,
|
||||||
|
// 'amount_original' => ,
|
||||||
|
// 'initialization_source' => ,
|
||||||
|
'bypass_3ds' => false,
|
||||||
|
// 'token'=> ,
|
||||||
|
'payment_source_id' => $request->payment_source,
|
||||||
|
// 'customer_id' => ,
|
||||||
|
'customer' => $this->getCustomer(),
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $this->stripe->init();
|
// $this->stripe->init();
|
||||||
|
|
||||||
// $state = [
|
// $state = [
|
||||||
|
@ -107,11 +107,12 @@ class CBAPowerBoardPaymentDriver extends BaseDriver
|
|||||||
* Detach payment method from custom payment driver.
|
* Detach payment method from custom payment driver.
|
||||||
*
|
*
|
||||||
* @param ClientGatewayToken $token
|
* @param ClientGatewayToken $token
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function detach(ClientGatewayToken $token): bool
|
public function detach(ClientGatewayToken $token): bool
|
||||||
{
|
{
|
||||||
// Driver doesn't support this feature.
|
// Driver doesn't support this feature.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refund(Payment $payment, $amount, $return_client_response = false)
|
public function refund(Payment $payment, $amount, $return_client_response = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user