Fixes for wepay

This commit is contained in:
David Bomba 2022-10-01 11:07:44 +10:00
parent 6d7ddc3beb
commit 0f1d9f68b9
7 changed files with 24 additions and 9 deletions

View File

@ -37,6 +37,7 @@ class CreditCard
public function authorizeView($data)
{
$data['gateway'] = $this->wepay_payment_driver;
$data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2;
return render('gateways.wepay.authorize.authorize', $data);
}
@ -101,6 +102,7 @@ class CreditCard
{
$data['gateway'] = $this->wepay_payment_driver;
$data['description'] = ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number');
$data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2;
return render('gateways.wepay.credit_card.pay', $data);
}

File diff suppressed because one or more lines are too long

View File

@ -22,7 +22,7 @@
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=2b2fe55f926789abc52f19111006e1ec",
"/js/clients/payments/braintree-credit-card.js": "/js/clients/payments/braintree-credit-card.js?id=cf25867ef09115b7f5a209819ba79bbf",
"/js/clients/payments/braintree-paypal.js": "/js/clients/payments/braintree-paypal.js?id=5764a8d406c1eda848d073f10d178626",
"/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=bec9106c8ba5a973acee4cfc47301324",
"/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=bafe2ca0bea073422a56fdb16da80869",
"/js/clients/payment_methods/wepay-bank-account.js": "/js/clients/payment_methods/wepay-bank-account.js?id=b8706d7de6127f184ad19b2a810880be",
"/js/clients/payments/paytrace-credit-card.js": "/js/clients/payments/paytrace-credit-card.js?id=e0b1231a7bf6252672836222285c0f52",
"/js/clients/payments/mollie-credit-card.js": "/js/clients/payments/mollie-credit-card.js?id=bbab588ed009a93345bec520cbe66869",

View File

@ -73,6 +73,13 @@ class WePayCreditCard {
cardButton.querySelector('svg').classList.remove('hidden');
cardButton.querySelector('span').classList.add('hidden');
var client_address = {};
client_address.country = document.querySelector(['meta[name=country_code']).content;
if(document.querySelector(['meta[name=country_code']).content == 'US'){
client_address.postal_code = document.querySelector(['meta[name=client-postal-code']).content;
}
WePay.credit_card.create({
client_id: document.querySelector('meta[name=wepay-client-id]').content,
user_name: document.getElementById('cardholder_name').value,
@ -81,9 +88,7 @@ class WePayCreditCard {
cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''),
expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''),
expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''),
address: {
postal_code: document.querySelector(['meta[name=client-postal-code']).content,
}
address: client_address
}, (data) => {
if (data.error) {
cardButton = document.getElementById('card_button');
@ -118,6 +123,13 @@ class WePayCreditCard {
return;
}
var client_address = {};
client_address.country = document.querySelector(['meta[name=country_code']).content;
if(document.querySelector(['meta[name=country_code']).content == 'US'){
client_address.postal_code = document.querySelector(['meta[name=client-postal-code']).content;
}
WePay.credit_card.create({
client_id: document.querySelector('meta[name=wepay-client-id]').content,
user_name: document.getElementById('cardholder_name').value,
@ -126,9 +138,7 @@ class WePayCreditCard {
cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''),
expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''),
expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''),
address: {
postal_code: document.querySelector(['meta[name=client-postal-code']).content,
}
address: client_address
}, (data) => {
if (data.error) {
this.payNowButton.disabled = false;

View File

@ -7,6 +7,7 @@
<meta name="contact-email" content="{{ $contact->email }}">
<meta name="client-postal-code" content="{{ $contact->client->postal_code }}">
<meta name="country_code" content="{{$country_code}}">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="{{ asset('js/clients/payments/card-js.min.js') }}"></script>

View File

@ -4,6 +4,7 @@
<meta name="wepay-environment" content="{{ config('ninja.wepay.environment') }}">
<meta name="wepay-client-id" content="{{ config('ninja.wepay.client_id') }}">
<meta name="contact-email" content="{{ $contact->email }}">
<meta name="country_code" content="{{$country_code}}">
<script type="text/javascript" src="https://static.wepay.com/min/js/tokenization.4.latest.js"></script>
@endsection

View File

@ -7,7 +7,8 @@
<meta name="contact-email" content="{{ $contact->email }}">
<meta name="client-postal-code" content="{{ $contact->client->postal_code }}">
<meta name="country_code" content="{{$country_code}}">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="{{ asset('js/clients/payments/card-js.min.js') }}"></script>