mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Pay with CC paytrace
This commit is contained in:
parent
211e6560fc
commit
1affdd7754
@ -479,7 +479,7 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
$this->client->company,
|
$this->client->company,
|
||||||
);
|
);
|
||||||
|
|
||||||
throw new PaymentFailed($error, $error_code);
|
throw new PaymentFailed($error, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ use App\Jobs\Mail\PaymentFailureMailer;
|
|||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentHash;
|
use App\Models\PaymentHash;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
@ -168,10 +169,12 @@ class CreditCard
|
|||||||
|
|
||||||
//process a regular charge here:
|
//process a regular charge here:
|
||||||
$data = [
|
$data = [
|
||||||
'hpf_token' => $data['HPF_Token'],
|
'hpf_token' => $response_array['HPF_Token'],
|
||||||
'enc_key' => $data['enc_key'],
|
'enc_key' => $response_array['enc_key'],
|
||||||
'integrator_id' => '959195xd1CuC',
|
'integrator_id' => '959195xd1CuC',
|
||||||
'billing_address' => $this->buildBillingAddress(),
|
'billing_address' => $this->buildBillingAddress(),
|
||||||
|
'amount' => $request->input('amount_with_fee'),
|
||||||
|
'invoice_id' => $this->harvestInvoiceId(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->paytrace_driver->gatewayRequest('/v1/transactions/sale/pt_protect', $data);
|
$response = $this->paytrace_driver->gatewayRequest('/v1/transactions/sale/pt_protect', $data);
|
||||||
@ -202,13 +205,22 @@ class CreditCard
|
|||||||
|
|
||||||
return $this->processUnsuccessfulPayment($response);
|
return $this->processUnsuccessfulPayment($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function harvestInvoiceId()
|
||||||
|
{
|
||||||
|
$_invoice = collect($this->paytrace_driver->payment_hash->data->invoices)->first();
|
||||||
|
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
|
||||||
|
|
||||||
|
if($invoice)
|
||||||
|
return ctrans('texts.invoice_number') . "# " . $invoice->number;
|
||||||
|
|
||||||
|
return ctrans('texts.invoice_number') . "####";
|
||||||
|
}
|
||||||
|
|
||||||
private function processSuccessfulPayment($response)
|
private function processSuccessfulPayment($response)
|
||||||
{
|
{
|
||||||
$amount = array_sum(array_column($this->paytrace_driver->payment_hash->invoices(), 'amount')) + $this->paytrace_driver->payment_hash->fee_total;
|
$amount = array_sum(array_column($this->paytrace_driver->payment_hash->invoices(), 'amount')) + $this->paytrace_driver->payment_hash->fee_total;
|
||||||
|
|
||||||
$response = $response_array;
|
|
||||||
|
|
||||||
$payment_record = [];
|
$payment_record = [];
|
||||||
$payment_record['amount'] = $amount;
|
$payment_record['amount'] = $amount;
|
||||||
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
|
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
|
||||||
@ -223,8 +235,12 @@ class CreditCard
|
|||||||
|
|
||||||
private function processUnsuccessfulPayment($response)
|
private function processUnsuccessfulPayment($response)
|
||||||
{
|
{
|
||||||
|
|
||||||
$error = $response->status_message;
|
$error = $response->status_message;
|
||||||
|
|
||||||
|
if(property_exists($response, 'approval_message') && $response->approval_message)
|
||||||
|
$error .= " - {$response->approval_message}";
|
||||||
|
|
||||||
$error_code = property_exists($response, 'approval_message') ? $response->approval_message : 'Undefined code';
|
$error_code = property_exists($response, 'approval_message') ? $response->approval_message : 'Undefined code';
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -234,6 +250,7 @@ class CreditCard
|
|||||||
];
|
];
|
||||||
|
|
||||||
return $this->paytrace_driver->processUnsuccessfulTransaction($data);
|
return $this->paytrace_driver->processUnsuccessfulTransaction($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
<input type="hidden" name="amount_with_fee" id="amount_with_fee" value="{{ $total['amount_with_fee'] }}"/>
|
<input type="hidden" name="amount_with_fee" id="amount_with_fee" value="{{ $total['amount_with_fee'] }}"/>
|
||||||
<input type="txt" id=HPF_Token name= HPF_Token hidden>
|
<input type="txt" id=HPF_Token name= HPF_Token hidden>
|
||||||
<input type="txt" id=enc_key name= enc_key hidden>
|
<input type="txt" id=enc_key name= enc_key hidden>
|
||||||
</form>
|
|
||||||
|
|
||||||
<div class="alert alert-failure mb-4" hidden id="errors"></div>
|
<div class="alert alert-failure mb-4" hidden id="errors"></div>
|
||||||
|
|
||||||
@ -52,14 +52,13 @@
|
|||||||
|
|
||||||
@include('portal.ninja2020.gateways.includes.save_card')
|
@include('portal.ninja2020.gateways.includes.save_card')
|
||||||
|
|
||||||
|
|
||||||
<div class="w-screen items-center" id="paytrace--credit-card-container">
|
<div class="w-screen items-center" id="paytrace--credit-card-container">
|
||||||
|
|
||||||
<div id='pt_hpf_form'><!--iframe sensitive data payment fields inserted here--></div>
|
<div id='pt_hpf_form'><!--iframe sensitive data payment fields inserted here--></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@include('portal.ninja2020.gateways.includes.pay_now')
|
@include('portal.ninja2020.gateways.includes.pay_now', ['type' => 'submit'])
|
||||||
|
</form>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('gateway_footer')
|
@section('gateway_footer')
|
||||||
@ -82,9 +81,6 @@
|
|||||||
.getElementById('token').value = e.target.dataset.token;
|
.getElementById('token').value = e.target.dataset.token;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var tokens = document.getElementsByClassName('toggle-payment-with-token');
|
|
||||||
tokens[0].click();
|
|
||||||
|
|
||||||
let payWithCreditCardToggle = document.getElementById('toggle-payment-with-credit-card');
|
let payWithCreditCardToggle = document.getElementById('toggle-payment-with-credit-card');
|
||||||
|
|
||||||
if (payWithCreditCardToggle) {
|
if (payWithCreditCardToggle) {
|
||||||
@ -97,12 +93,12 @@
|
|||||||
|
|
||||||
document
|
document
|
||||||
.getElementById('token').value = null;
|
.getElementById('token').value = null;
|
||||||
|
|
||||||
token_payment = false;
|
token_payment = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tokens = document.getElementsByClassName('toggle-payment-with-token');
|
||||||
|
tokens[0].click();
|
||||||
|
|
||||||
// Minimal Protect.js setup call
|
// Minimal Protect.js setup call
|
||||||
PTPayment.setup({
|
PTPayment.setup({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user