diff --git a/app/PaymentDrivers/Braintree/ACH.php b/app/PaymentDrivers/Braintree/ACH.php index 25cd07e2c..de109c54c 100644 --- a/app/PaymentDrivers/Braintree/ACH.php +++ b/app/PaymentDrivers/Braintree/ACH.php @@ -13,7 +13,6 @@ namespace App\PaymentDrivers\Braintree; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -23,6 +22,7 @@ use App\Models\SystemLog; use App\PaymentDrivers\BraintreePaymentDriver; use App\PaymentDrivers\Common\MethodInterface; use App\Utils\Traits\MakesHash; +use Illuminate\Http\Request; class ACH implements MethodInterface { diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index 4a858b0ff..cd00111dc 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\CheckoutCom; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\PaymentDrivers\CheckoutComPaymentDriver; diff --git a/app/PaymentDrivers/Common/MethodInterface.php b/app/PaymentDrivers/Common/MethodInterface.php index 0c839d602..2febf2c2f 100644 --- a/app/PaymentDrivers/Common/MethodInterface.php +++ b/app/PaymentDrivers/Common/MethodInterface.php @@ -12,7 +12,7 @@ namespace App\PaymentDrivers\Common; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; interface MethodInterface { diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index 1242cc022..e620db4d5 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\GoCardless; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index 0507c38f6..5b9207ad1 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\GoCardless; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; diff --git a/app/PaymentDrivers/GoCardless/SEPA.php b/app/PaymentDrivers/GoCardless/SEPA.php index a215b975e..9eef98e8f 100644 --- a/app/PaymentDrivers/GoCardless/SEPA.php +++ b/app/PaymentDrivers/GoCardless/SEPA.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\GoCardless; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; diff --git a/app/PaymentDrivers/Mollie/Bancontact.php b/app/PaymentDrivers/Mollie/Bancontact.php index d8a0eab78..45df88520 100644 --- a/app/PaymentDrivers/Mollie/Bancontact.php +++ b/app/PaymentDrivers/Mollie/Bancontact.php @@ -13,7 +13,7 @@ namespace App\PaymentDrivers\Mollie; use App\Exceptions\PaymentFailed; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; diff --git a/app/PaymentDrivers/Mollie/BankTransfer.php b/app/PaymentDrivers/Mollie/BankTransfer.php index 3002d201c..04e65996c 100644 --- a/app/PaymentDrivers/Mollie/BankTransfer.php +++ b/app/PaymentDrivers/Mollie/BankTransfer.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\Mollie; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; use App\Models\Payment; diff --git a/app/PaymentDrivers/Mollie/IDEAL.php b/app/PaymentDrivers/Mollie/IDEAL.php index 20ac61b3c..185cfe758 100644 --- a/app/PaymentDrivers/Mollie/IDEAL.php +++ b/app/PaymentDrivers/Mollie/IDEAL.php @@ -14,7 +14,7 @@ namespace App\PaymentDrivers\Mollie; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; use App\Models\Payment; diff --git a/app/PaymentDrivers/Mollie/KBC.php b/app/PaymentDrivers/Mollie/KBC.php index d608a62b8..1bb575d1b 100644 --- a/app/PaymentDrivers/Mollie/KBC.php +++ b/app/PaymentDrivers/Mollie/KBC.php @@ -13,7 +13,7 @@ namespace App\PaymentDrivers\Mollie; use App\Exceptions\PaymentFailed; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; diff --git a/app/PaymentDrivers/Razorpay/Hosted.php b/app/PaymentDrivers/Razorpay/Hosted.php index 657cd4d5d..1eb45072a 100644 --- a/app/PaymentDrivers/Razorpay/Hosted.php +++ b/app/PaymentDrivers/Razorpay/Hosted.php @@ -15,7 +15,7 @@ namespace App\PaymentDrivers\Razorpay; use App\Exceptions\PaymentFailed; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; use App\Models\Payment; diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index 47867fa3b..01696fd43 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -13,16 +13,20 @@ namespace App\PaymentDrivers\Square; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use Illuminate\Http\Request; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; use App\Models\PaymentType; +use App\PaymentDrivers\Common\MethodInterface; use App\PaymentDrivers\SquarePaymentDriver; use App\Utils\Traits\MakesHash; +use Illuminate\Http\RedirectResponse; use Illuminate\Support\Str; +use Illuminate\View\View; use Square\Http\ApiResponse; -class CreditCard +class CreditCard implements MethodInterface { use MakesHash; @@ -34,90 +38,27 @@ class CreditCard $this->square_driver->init(); } - public function authorizeView($data) + /** + * Authorization page for credit card. + * + * @param array $data + * @return View + */ + public function authorizeView($data): View { $data['gateway'] = $this->square_driver; return render('gateways.square.credit_card.authorize', $data); } - public function authorizeResponse($request) + /** + * Handle authorization for credit card. + * + * @param Request $request + * @return RedirectResponse + */ + public function authorizeResponse($request): RedirectResponse { - /* Step one - process a $1 payment - but don't complete it*/ - $payment = false; - - $amount_money = new \Square\Models\Money(); - $amount_money->setAmount(100); //amount in cents - $amount_money->setCurrency($this->square_driver->client->currency()->code); - - $body = new \Square\Models\CreatePaymentRequest( - $request->sourceId, - Str::random(32), - $amount_money - ); - - $body->setAutocomplete(false); - $body->setLocationId($this->square_driver->company_gateway->getConfigField('locationId')); - $body->setReferenceId(Str::random(16)); - - $api_response = $this->square_driver->square->getPaymentsApi()->createPayment($body); - - if ($api_response->isSuccess()) { - $result = $api_response->getBody(); - $payment = json_decode($result); - } else { - $errors = $api_response->getErrors(); - return $this->processUnsuccessfulPayment($errors); - } - - - /* Step 3 create the card */ - $card = new \Square\Models\Card(); - $card->setCardholderName($this->square_driver->client->present()->name()); - // $card->setBillingAddress($billing_address); - $card->setCustomerId($this->findOrCreateClient()); - $card->setReferenceId(Str::random(8)); - - $body = new \Square\Models\CreateCardRequest( - Str::random(32), - $payment->payment->id, - $card - ); - - $api_response = $this->square_driver - ->square - ->getCardsApi() - ->createCard($body); - - $card = false; - - if ($api_response->isSuccess()) { - $card = $api_response->getBody(); - $card = json_decode($card); - } else { - $errors = $api_response->getErrors(); - - return $this->processUnsuccessfulPayment($errors); - } - - /* Create the token in Invoice Ninja*/ - $cgt = []; - $cgt['token'] = $card->card->id; - $cgt['payment_method_id'] = GatewayType::CREDIT_CARD; - - $payment_meta = new \stdClass; - $payment_meta->exp_month = $card->card->exp_month; - $payment_meta->exp_year = $card->card->exp_year; - $payment_meta->brand = $card->card->card_brand; - $payment_meta->last4 = $card->card->last_4; - $payment_meta->type = GatewayType::CREDIT_CARD; - - $cgt['payment_meta'] = $payment_meta; - - $token = $this->square_driver->storeGatewayToken($cgt, [ - 'gateway_customer_reference' => $this->findOrCreateClient(), - ]); - return redirect()->route('client.payment_methods.index'); } @@ -170,8 +111,9 @@ class CreditCard $body->setLocationId($this->square_driver->company_gateway->getConfigField('locationId')); $body->setReferenceId(Str::random(16)); - if($request->has('verificationToken') && $request->input('verificationToken')) + if ($request->has('verificationToken') && $request->input('verificationToken')) { $body->setVerificationToken($request->input('verificationToken')); + } if ($request->shouldUseToken()) { $body->setCustomerId($cgt->gateway_customer_reference); @@ -181,66 +123,12 @@ class CreditCard $response = $this->square_driver->square->getPaymentsApi()->createPayment($body); if ($response->isSuccess()) { - if ($request->shouldStoreToken()) { - $this->storePaymentMethod($response); - } - return $this->processSuccessfulPayment($response); } return $this->processUnsuccessfulPayment($response); } - private function storePaymentMethod(ApiResponse $response) - { - $payment = \json_decode($response->getBody()); - - $billing_address = new \Square\Models\Address(); - $billing_address->setAddressLine1($this->square_driver->client->address1); - $billing_address->setAddressLine2($this->square_driver->client->address2); - $billing_address->setLocality($this->square_driver->client->city); - $billing_address->setAdministrativeDistrictLevel1($this->square_driver->client->state); - $billing_address->setPostalCode($this->square_driver->client->postal_code); - $billing_address->setCountry($this->square_driver->client->country->iso_3166_2); - - $card = new \Square\Models\Card(); - $card->setCardholderName($this->square_driver->client->present()->first_name(). " " .$this->square_driver->client->present()->last_name()); - $card->setCustomerId($this->findOrCreateClient()); - $card->setReferenceId(Str::random(8)); - $card->setBillingAddress($billing_address); - - $body = new \Square\Models\CreateCardRequest(Str::random(32), $payment->payment->id, $card); - - /** @var ApiResponse */ - $api_response = $this->square_driver - ->square - ->getCardsApi() - ->createCard($body); - - if (!$api_response->isSuccess()) { - return $this->processUnsuccessfulPayment($api_response); - } - - $card = \json_decode($api_response->getBody()); - - $cgt = []; - $cgt['token'] = $card->card->id; - $cgt['payment_method_id'] = GatewayType::CREDIT_CARD; - - $payment_meta = new \stdClass; - $payment_meta->exp_month = $card->card->exp_month; - $payment_meta->exp_year = $card->card->exp_year; - $payment_meta->brand = $card->card->card_brand; - $payment_meta->last4 = $card->card->last_4; - $payment_meta->type = GatewayType::CREDIT_CARD; - - $cgt['payment_meta'] = $payment_meta; - - $this->square_driver->storeGatewayToken($cgt, [ - 'gateway_customer_reference' => $this->findOrCreateClient(), - ]); - } - private function processSuccessfulPayment(ApiResponse $response) { $body = json_decode($response->getBody()); @@ -301,9 +189,9 @@ class CreditCard $customers = $api_response->getBody(); $customers = json_decode($customers); - if(count(array($api_response->getBody(),1)) == 0) + if (count([$api_response->getBody(),1]) == 0) { $customers = false; - + } } else { $errors = $api_response->getErrors(); } diff --git a/public/js/clients/payments/square-credit-card.js b/public/js/clients/payments/square-credit-card.js index 215fa587e..b6753383c 100644 --- a/public/js/clients/payments/square-credit-card.js +++ b/public/js/clients/payments/square-credit-card.js @@ -1,2 +1,2 @@ /*! For license information please see square-credit-card.js.LICENSE.txt */ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=25)}({25:function(t,e,n){t.exports=n("flnV")},flnV:function(t,e,n){"use strict";n.r(e);var r=n("o0o1"),o=n.n(r);function a(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function i(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function c(t){a(i,r,o,c,u,"next",t)}function u(t){a(i,r,o,c,u,"throw",t)}c(void 0)}))}}function c(t,e){for(var n=0;n=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},o0o1:function(t,e,n){t.exports=n("ls82")}}); \ No newline at end of file +!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=25)}({25:function(t,e,n){t.exports=n("flnV")},flnV:function(t,e,n){"use strict";n.r(e);var r=n("o0o1"),o=n.n(r);function a(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function i(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function c(t){a(i,r,o,c,u,"next",t)}function u(t){a(i,r,o,c,u,"throw",t)}c(void 0)}))}}function c(t,e){for(var n=0;n=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},o0o1:function(t,e,n){t.exports=n("ls82")}}); \ No newline at end of file diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 1d81c0bd0..d0bd4c936 100755 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,6 +1,6 @@ { - "/js/app.js": "/js/app.js?id=019831a9b0c0aff43c7f", - "/css/app.css": "/css/app.css?id=df1ea83ea621533ac837", + "/js/app.js": "/js/app.js?id=696e8203d5e8e7cf5ff5", + "/css/app.css": "/css/app.css?id=f7f7b35aa3f417a3eca3", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1", "/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7", @@ -17,7 +17,7 @@ "/js/clients/payments/mollie-credit-card.js": "/js/clients/payments/mollie-credit-card.js?id=73b66e88e2daabcd6549", "/js/clients/payments/paytrace-credit-card.js": "/js/clients/payments/paytrace-credit-card.js?id=c2b5f7831e1a46dd5fb2", "/js/clients/payments/razorpay-aio.js": "/js/clients/payments/razorpay-aio.js?id=817ab3b2b94ee37b14eb", - "/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=070c86b293b532c5a56c", + "/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=13ea3ff41d9417ef0140", "/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=81c2623fc1e5769b51c7", "/js/clients/payments/stripe-acss.js": "/js/clients/payments/stripe-acss.js?id=4a85142c085723991d28", "/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=665ddf663500767f1a17", @@ -36,6 +36,6 @@ "/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45", "/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=2a99d83305ba87bfa6cc", "/js/clients/statements/view.js": "/js/clients/statements/view.js?id=ca3ec4cea0de824f3a36", - "/js/setup/setup.js": "/js/setup/setup.js?id=03ea88a737e59eb2bd5a", + "/js/setup/setup.js": "/js/setup/setup.js?id=8d454e7090f119552a6c", "/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad" } diff --git a/resources/js/clients/payments/square-credit-card.js b/resources/js/clients/payments/square-credit-card.js index 011a4c63e..cceaacc5a 100644 --- a/resources/js/clients/payments/square-credit-card.js +++ b/resources/js/clients/payments/square-credit-card.js @@ -43,57 +43,39 @@ class SquareCreditCard { } } - // , - // function(err,verification) { - // if (err == null) { - // console.log("no error"); - // console.log(verification); - // verificationToken = verificationResults.token; - - // } - - // console.log(err); - - // die("verify buyer"); - // } - - async completePaymentWithoutToken(e) { document.getElementById('errors').hidden = true; e.target.parentElement.disabled = true; let result = await this.card.tokenize(); - console.log("square token = " + result.token); - /* SCA */ - let verificationToken; + let verificationToken; - try { - const verificationDetails = { - amount: document.querySelector('meta[name=amount]').content, - billingContact: JSON.parse(document.querySelector('meta[name=square_contact]').content), - currencyCode: document.querySelector('meta[name=currencyCode]').content, - intent: 'CHARGE' - }; - - console.log(verificationDetails); + try { + const verificationDetails = { + amount: document.querySelector('meta[name=amount]').content, + billingContact: JSON.parse( + document.querySelector('meta[name=square_contact]').content + ), + currencyCode: document.querySelector('meta[name=currencyCode]') + .content, + intent: 'CHARGE', + }; const verificationResults = await this.payments.verifyBuyer( - result.token, - verificationDetails + result.token, + verificationDetails ); verificationToken = verificationResults.token; - } - catch(typeError){ - console.log(typeError); + } catch (typeError) { + e.target.parentElement.disabled = true } - console.debug('Verification Token:', verificationToken); - - document.querySelector('input[name="verificationToken"]').value = - verificationToken; + document.querySelector( + 'input[name="verificationToken"]' + ).value = verificationToken; if (result.status === 'OK') { document.getElementById('sourceId').value = result.token; @@ -125,23 +107,20 @@ class SquareCreditCard { /* SCA */ async verifyBuyer(token) { - - console.log("in verify buyer"); - const verificationDetails = { - amount: document.querySelector('meta[name=amount]').content, - billingContact: document.querySelector('meta[name=square_contact]').content, - currencyCode: document.querySelector('meta[name=currencyCode]').content, - intent: 'CHARGE' + amount: document.querySelector('meta[name=amount]').content, + billingContact: document.querySelector('meta[name=square_contact]') + .content, + currencyCode: document.querySelector('meta[name=currencyCode]') + .content, + intent: 'CHARGE', }; const verificationResults = await this.payments.verifyBuyer( - token, - verificationDetails + token, + verificationDetails ); - console.log(" verification toke = " + verificationResults.token); - return verificationResults.token; } diff --git a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php index 5278f6c32..b0eecc44c 100644 --- a/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/square/credit_card/authorize.blade.php @@ -1,37 +1,7 @@ -@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' -=> ctrans('texts.payment_type_credit_card')]) - -@section('gateway_head') - - - -@endsection +@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')]) @section('gateway_content') -
- @csrf - -
- - - @component('portal.ninja2020.components.general.card-element-single') -
-
- @endcomponent - - @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-card']) - {{ ctrans('texts.add_payment_method') }} + {{ __('texts.payment_method_cannot_be_preauthorized') }} @endcomponent @endsection - -@section('gateway_footer') - @if ($gateway->company_gateway->getConfigField('testMode')) - - @else - - @endif - - -@endsection