This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from revosystems/feature/REV-11510
feature: add operation to tokenize cards and add charge with tokenized card without interface.
- Loading branch information
Showing
16 changed files
with
323 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Revosystems\Redsys\Http\Livewire; | ||
|
||
use Livewire\Component; | ||
use Revosystems\Redsys\Models\ChargeResult; | ||
use Revosystems\Redsys\Services\RedsysChargePayment; | ||
use Revosystems\Redsys\Services\RedsysChargeRequest; | ||
use Revosystems\Redsys\Models\RedsysPaymentGateway; | ||
|
||
class RedsysTokenizeForm extends Component | ||
{ | ||
protected $listeners = [ | ||
'onCardFormSubmit', | ||
'onTokenizeCompleted', | ||
]; | ||
|
||
public $paymentReference; | ||
public $iframeUrl; | ||
public $redsysFormId; | ||
|
||
public function mount(string $redsysFormId, string $paymentReference) | ||
{ | ||
$this->redsysFormId = $redsysFormId; | ||
$this->paymentReference = $paymentReference; | ||
$this->iframeUrl = RedsysPaymentGateway::get()->isTestEnvironment() ? 'https://sis-t.redsys.es:25443/sis/NC/sandbox/redsysV2.js' : 'https://sis.redsys.es/sis/NC/redsysV2.js'; | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('redsys::livewire.redsys-tokenize-form'); | ||
} | ||
|
||
public function onTokenizeCompleted(ChargeResult $data) : void | ||
{ | ||
RedsysChargePayment::get($this->paymentReference)->payHandler->onPaymentSucceed($this->paymentReference, $data); | ||
} | ||
|
||
public function onCardFormSubmit(string $operationId, array $extraInfo) : void | ||
{ | ||
$chargeRequest = RedsysChargeRequest::makeWithOperationId($this->paymentReference, $operationId, $extraInfo); | ||
$chargeRequest->customerToken = 'customer_token'; | ||
$this->emit('payResponse', RedsysPaymentGateway::get()->tokenizeCard( | ||
RedsysChargePayment::get($this->paymentReference), | ||
$chargeRequest | ||
)->gatewayResponse); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
|
||
namespace Revosystems\Redsys\Services; | ||
|
||
use Revosystems\Redsys\Models\RedsysPaymentHandler; | ||
|
||
class RedsysTokenizeCardChargePayment extends RedsysChargePayment | ||
{ | ||
|
||
public function __construct(RedsysPaymentHandler $payHandler, string $externalReference, string $tenant) | ||
{ | ||
parent::__construct($payHandler, $externalReference, $tenant, 0, 'EUR'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div :id="'new-card-mode'" :name="'mode'"> | ||
@include('redsys::tokenize.iframe', compact('iframeUrl')) | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script src="{{ $iframeUrl }}"></script> | ||
<div id="{{ $redsysFormId }}" style="height: 500px; margin: auto;" wire:ignore> | ||
</div> | ||
<input type="hidden" id="token"/> | ||
<input type="hidden" id="errorCode"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@extends(config('redsys.indexLayout')) | ||
|
||
@section('redsys-head') | ||
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script> | ||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
{!! \Khill\FontAwesome\FontAwesome::css() !!} | ||
@endsection | ||
|
||
@section('content') | ||
|
||
<div class="w-full flex flex-col space-y-4 h-full" style="height: 100%; min-height: 200px; margin-top: 24px"> | ||
@include('redsys::tokenize.main', [ | ||
'redsysFormId' => 'redsys-init-form', | ||
'redsysConfig' => $redsysConfig, | ||
'paymentReference' => $paymentReference, | ||
'chargePayment' => $chargePayment, | ||
]) | ||
</div> | ||
@endsection |
Oops, something went wrong.