mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Square: New payment flow (#75)
* pass livewirePaymentView & processPaymentView thru base driver * square
This commit is contained in:
parent
339a92fa6f
commit
eb1576aa7c
@ -21,6 +21,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\PaymentDrivers\SquarePaymentDriver;
|
use App\PaymentDrivers\SquarePaymentDriver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -29,7 +30,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Square\Http\ApiResponse;
|
use Square\Http\ApiResponse;
|
||||||
|
|
||||||
class CreditCard implements MethodInterface
|
class CreditCard implements MethodInterface, LivewireMethodInterface
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
@ -64,10 +65,7 @@ class CreditCard implements MethodInterface
|
|||||||
|
|
||||||
public function paymentView($data)
|
public function paymentView($data)
|
||||||
{
|
{
|
||||||
$data['gateway'] = $this->square_driver;
|
$data = $this->paymentData($data);
|
||||||
$data['amount'] = $this->square_driver->payment_hash->data->amount_with_fee;
|
|
||||||
$data['currencyCode'] = $this->square_driver->client->getCurrencyCode();
|
|
||||||
$data['square_contact'] = $this->buildClientObject();
|
|
||||||
|
|
||||||
return render('gateways.square.credit_card.pay', $data);
|
return render('gateways.square.credit_card.pay', $data);
|
||||||
}
|
}
|
||||||
@ -238,5 +236,24 @@ class CreditCard implements MethodInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function livewirePaymentView(array $data): string
|
||||||
|
{
|
||||||
|
return 'gateways.square.credit_card.pay_livewire';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function paymentData(array $data): array
|
||||||
|
{
|
||||||
|
$data['gateway'] = $this->square_driver;
|
||||||
|
$data['amount'] = $this->square_driver->payment_hash->data->amount_with_fee;
|
||||||
|
$data['currencyCode'] = $this->square_driver->client->getCurrencyCode();
|
||||||
|
$data['square_contact'] = $this->buildClientObject();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
* @license https://www.elastic.co/licensing/elastic-license
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { wait, instant } from '../wait';
|
||||||
|
|
||||||
class SquareCreditCard {
|
class SquareCreditCard {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.appId = document.querySelector('meta[name=square-appId]').content;
|
this.appId = document.querySelector('meta[name=square-appId]').content;
|
||||||
@ -180,4 +182,9 @@ class SquareCreditCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new SquareCreditCard().handle();
|
function boot() {
|
||||||
|
new SquareCreditCard().handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
instant() ? boot() : wait('#square-credit-card-payment').then(() => boot());
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<meta name="square_contact" content="{{ json_encode($square_contact) }}">
|
<meta name="square_contact" content="{{ json_encode($square_contact) }}">
|
||||||
<meta name="amount" content="{{ $amount }}">
|
<meta name="amount" content="{{ $amount }}">
|
||||||
<meta name="currencyCode" content="{{ $currencyCode }}">
|
<meta name="currencyCode" content="{{ $currencyCode }}">
|
||||||
|
<meta name="instant-payment" content="yes" />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.loader {
|
.loader {
|
||||||
border-top-color: #3498db;
|
border-top-color: #3498db;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user