1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #6758 from turbo124/v5-develop

Minor fixes for PostMark Delivery
This commit is contained in:
David Bomba 2021-10-03 15:57:40 +11:00 committed by GitHub
commit e9be7a46d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 111 additions and 4 deletions

View File

@ -11,7 +11,6 @@
namespace App\Http\Controllers;
use App\DataMapper\Analytics\EmailBounce;
use App\DataMapper\Analytics\Mail\EmailBounce;
use App\DataMapper\Analytics\Mail\EmailSpam;
use App\Jobs\Util\SystemLogger;

View File

@ -41,6 +41,16 @@ class ClientPresenter extends EntityPresenter
return $contact_name;
}
public function first_name()
{
return $this->entity->primary_contact->first() !== null ? $this->entity->primary_contact->first()->first_name : $this->entity->contacts()->first()->first_name;
}
public function last_name()
{
return $this->entity->primary_contact->first() !== null ? $this->entity->primary_contact->first()->last_name : $this->entity->contacts()->first()->last_name;
}
public function primary_contact_name()
{
return $this->entity->primary_contact->first() !== null ? $this->entity->primary_contact->first()->first_name.' '.$this->entity->primary_contact->first()->last_name : 'No primary contact set';

View File

@ -124,11 +124,29 @@ class CreditCard
public function paymentView($data)
{
$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 render('gateways.square.credit_card.pay', $data);
}
private function buildClientObject()
{
$client = new \stdClass;
$client->addressLines = [ $this->square_driver->client->address1 ?: '', $this->square_driver->client->address2 ?: ''];
$client->givenName = $this->square_driver->client->present()->first_name();
$client->familyName = $this->square_driver->client->present()->last_name();
$client->email = $this->square_driver->client->present()->email;
$client->phone = $this->square_driver->client->phone;
$client->city = $this->square_driver->client->city;
$client->region = $this->square_driver->client->state;
$client->country = $this->square_driver->client->country->iso_3166_2;
return (array)$client;
}
public function paymentResponse(PaymentResponseRequest $request)
{
$token = $request->sourceId;
@ -152,6 +170,9 @@ class CreditCard
$body->setLocationId($this->square_driver->company_gateway->getConfigField('locationId'));
$body->setReferenceId(Str::random(16));
if($request->has('verificationToken') && $request->input('verificationToken'))
$body->setVerificationToken($request->input('verificationToken'));
if ($request->shouldUseToken()) {
$body->setCustomerId($cgt->gateway_customer_reference);
}

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@
"/js/clients/payments/eway-credit-card.js": "/js/clients/payments/eway-credit-card.js?id=08ea84e9451abd434cff",
"/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/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=994c79534ee0a7391f69",
"/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=070c86b293b532c5a56c",
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=81c2623fc1e5769b51c7",
"/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=665ddf663500767f1a17",
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=a30464874dee84678344",

View File

@ -43,12 +43,62 @@ 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;
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);
const verificationResults = await this.payments.verifyBuyer(
result.token,
verificationDetails
);
verificationToken = verificationResults.token;
}
catch(typeError){
console.log(typeError);
die("failed in the catch");
}
// console.log(" verification tokem = " + verificationToken.token);
// verificationToken = verificationResults.token;
console.debug('Verification Token:', verificationToken);
document.querySelector('input[name="verificationToken"]').value =
verificationToken;
if (result.status === 'OK') {
document.getElementById('sourceId').value = result.token;
@ -77,6 +127,28 @@ class SquareCreditCard {
return document.getElementById('server_response').submit();
}
/* 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'
};
const verificationResults = await this.payments.verifyBuyer(
token,
verificationDetails
);
console.log(" verification toke = " + verificationResults.token);
return verificationResults.token;
}
async handle() {
await this.init();

View File

@ -4,6 +4,10 @@
@section('gateway_head')
<meta name="square-appId" content="{{ $gateway->company_gateway->getConfigField('applicationId') }}">
<meta name="square-locationId" content="{{ $gateway->company_gateway->getConfigField('locationId') }}">
<meta name="square_contact" content="{{ json_encode($square_contact) }}">
<meta name="amount" content="{{ $amount }}">
<meta name="currencyCode" content="{{ $currencyCode }}">
@endsection
@section('gateway_content')
@ -17,6 +21,7 @@
<input type="hidden" name="token">
<input type="hidden" name="sourceId" id="sourceId">
<input type="hidden" name="verificationToken" id="verificationToken">
</form>
<div class="alert alert-failure mb-4" hidden id="errors"></div>