mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Authorize a card with Paytrace
This commit is contained in:
parent
87e1ba48e9
commit
f0b232c1a2
@ -51,8 +51,6 @@ class CreditCard
|
|||||||
{
|
{
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
|
||||||
nlog($data);
|
|
||||||
|
|
||||||
$post_data = [
|
$post_data = [
|
||||||
'customer_id' => Str::random(32),
|
'customer_id' => Str::random(32),
|
||||||
'hpf_token' => $data['HPF_Token'],
|
'hpf_token' => $data['HPF_Token'],
|
||||||
@ -67,8 +65,6 @@ class CreditCard
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
nlog($post_data);
|
|
||||||
|
|
||||||
// "_token" => "Vl1xHflBYQt9YFSaNCPTJKlY5x3rwcFE9kvkw71I"
|
// "_token" => "Vl1xHflBYQt9YFSaNCPTJKlY5x3rwcFE9kvkw71I"
|
||||||
// "company_gateway_id" => "1"
|
// "company_gateway_id" => "1"
|
||||||
// "HPF_Token" => "e484a92c-90ed-4468-ac4d-da66824c75de"
|
// "HPF_Token" => "e484a92c-90ed-4468-ac4d-da66824c75de"
|
||||||
@ -93,10 +89,30 @@ class CreditCard
|
|||||||
|
|
||||||
// dd($response);
|
// dd($response);
|
||||||
|
|
||||||
// +"success": true
|
// +"success": true
|
||||||
// +"response_code": 160
|
// +"response_code": 160
|
||||||
// +"status_message": "The customer profile for PLS5U60OoLUfQXzcmtJYNefPA0gTthzT/11 was successfully created."
|
// +"status_message": "The customer profile for PLS5U60OoLUfQXzcmtJYNefPA0gTthzT/11 was successfully created."
|
||||||
// +"customer_id": "PLS5U60OoLUfQXzcmtJYNefPA0gTthzT"
|
// +"customer_id": "PLS5U60OoLUfQXzcmtJYNefPA0gTthzT"
|
||||||
|
|
||||||
|
// if(!$response->success)
|
||||||
|
//handle failure
|
||||||
|
|
||||||
|
$cgt = [];
|
||||||
|
$cgt['token'] = $response->customer_id;
|
||||||
|
$cgt['payment_method_id'] = GatewayType::CREDIT_CARD;
|
||||||
|
|
||||||
|
$profile = $this->getCustomerProfile($response->customer_id);
|
||||||
|
|
||||||
|
$payment_meta = new \stdClass;
|
||||||
|
$payment_meta->exp_month = $profile->credit_card->expiration_month;
|
||||||
|
$payment_meta->exp_year = $profile->credit_card->expiration_year;
|
||||||
|
$payment_meta->brand = 'CC';
|
||||||
|
$payment_meta->last4 = $profile->credit_card->masked_number;
|
||||||
|
$payment_meta->type = GatewayType::CREDIT_CARD;
|
||||||
|
|
||||||
|
$cgt['payment_meta'] = $payment_meta;
|
||||||
|
|
||||||
|
$token = $this->paytrace_driver->storeGatewayToken($cgt, []);
|
||||||
|
|
||||||
|
|
||||||
// make a cc card out of that bra
|
// make a cc card out of that bra
|
||||||
@ -104,6 +120,19 @@ class CreditCard
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getCustomerProfile($customer_id)
|
||||||
|
{
|
||||||
|
$profile = $this->paytrace_driver->gatewayRequest('/v1/customer/export', [
|
||||||
|
'integrator_id' => '959195xd1CuC',
|
||||||
|
'customer_id' => $customer_id,
|
||||||
|
// 'include_bin' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $profile->customers[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function paymentView($data)
|
public function paymentView($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -123,20 +123,21 @@ class PaytracePaymentDriver extends BaseDriver
|
|||||||
public function getAuthToken()
|
public function getAuthToken()
|
||||||
{
|
{
|
||||||
|
|
||||||
$headers = $this->generateAuthHeaders();
|
$headers = $this->generateAuthHeaders();
|
||||||
|
|
||||||
$response = CurlUtils::post('https://api.paytrace.com/v1/payment_fields/token/create', [], $headers);
|
$response = CurlUtils::post('https://api.paytrace.com/v1/payment_fields/token/create', [], $headers);
|
||||||
|
|
||||||
$response = json_decode($response);
|
$response = json_decode($response);
|
||||||
|
|
||||||
if($response)
|
if($response)
|
||||||
return $response->clientKey;
|
return $response->clientKey;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gatewayRequest($uri, $data, $headers = false)
|
public function gatewayRequest($uri, $data, $headers = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$base_url = "https://api.paytrace.com{$uri}";
|
$base_url = "https://api.paytrace.com{$uri}";
|
||||||
|
|
||||||
$headers = $this->generateAuthHeaders();
|
$headers = $this->generateAuthHeaders();
|
||||||
@ -149,5 +150,6 @@ class PaytracePaymentDriver extends BaseDriver
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ PTPayment.setup({
|
|||||||
}).then(function(instance){
|
}).then(function(instance){
|
||||||
|
|
||||||
|
|
||||||
PTPayment.getControl("securityCode").label.text("CSC");
|
PTPayment.getControl("securityCode").label.text("{!! ctrans('texts.cvv')!!}");
|
||||||
PTPayment.getControl("creditCard").label.text("CC#");
|
PTPayment.getControl("creditCard").label.text("{!! ctrans('texts.card_number')!!}");
|
||||||
PTPayment.getControl("expiration").label.text("Exp Date");
|
PTPayment.getControl("expiration").label.text("{!! ctrans('texts.expires')!!}");
|
||||||
//PTPayment.style({'cc': {'label_color': 'red'}});
|
//PTPayment.style({'cc': {'label_color': 'red'}});
|
||||||
//PTPayment.style({'code': {'label_color': 'red'}});
|
//PTPayment.style({'code': {'label_color': 'red'}});
|
||||||
//PTPayment.style({'exp': {'label_color': 'red'}});
|
//PTPayment.style({'exp': {'label_color': 'red'}});
|
||||||
@ -100,12 +100,15 @@ PTPayment.setup({
|
|||||||
|
|
||||||
// To trigger the validation of sensitive data payment fields within the iframe before calling the tokenization process:
|
// To trigger the validation of sensitive data payment fields within the iframe before calling the tokenization process:
|
||||||
PTPayment.validate(function(validationErrors) {
|
PTPayment.validate(function(validationErrors) {
|
||||||
|
|
||||||
if (validationErrors.length >= 1) {
|
if (validationErrors.length >= 1) {
|
||||||
if (validationErrors[0]['responseCode'] == '35') {
|
|
||||||
// Handle validation Errors here
|
let errors = document.getElementById('errors');
|
||||||
// This is an example of using dynamic styling to show the Credit card number entered is invalid
|
|
||||||
instance.style({'cc': {'border_color': 'red'}});
|
errors.textContent = '';
|
||||||
}
|
errors.textContent = validationErrors[0].description;
|
||||||
|
errors.hidden = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no error so tokenize
|
// no error so tokenize
|
||||||
instance.process()
|
instance.process()
|
||||||
@ -123,9 +126,7 @@ PTPayment.setup({
|
|||||||
|
|
||||||
|
|
||||||
function handleError(err){
|
function handleError(err){
|
||||||
|
document.write(JSON.stringify(err));
|
||||||
|
|
||||||
document.write(JSON.stringify(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitPayment(r){
|
function submitPayment(r){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user