Working on authorize

This commit is contained in:
David Bomba 2020-06-09 21:53:23 +10:00
parent d58c2f05ff
commit 6c7ca0d8c9
5 changed files with 108 additions and 62 deletions

View File

@ -80,7 +80,7 @@ class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
{
$data['gateway'] = $this->gateway;
return render($this->viewForType(GatewayType::CREDIT_CARD), $data);
return render('gateways.authorize.add_credit_card', $data);
}
public function authorizeCreditCardResponse($request)

View File

@ -14,8 +14,10 @@ namespace App\PaymentDrivers;
use net\authorize\api\constants\ANetEnvironment;
use net\authorize\api\contract\v1\CreateTransactionRequest;
use net\authorize\api\contract\v1\GetMerchantDetailsRequest;
use net\authorize\api\contract\v1\MerchantAuthenticationType;
use net\authorize\api\controller\CreateTransactionController;
use net\authorize\api\controller\GetMerchantDetailsController;
/**
* Class BaseDriver
@ -25,36 +27,59 @@ use net\authorize\api\controller\CreateTransactionController;
class AuthorizePaymentDriver extends BaseDriver
{
public $anet;
public $merchant_authentication;
public function init()
{
error_reporting (E_ALL & ~E_DEPRECATED);
$merchantAuthentication = new MerchantAuthenticationType();
$merchantAuthentication->setName($this->company_gateway->getConfigField('apiLoginId'));
$merchantAuthentication->setTransactionKey($this->company_gateway->getConfigField('transactionKey'));
$this->anet = new CreateTransactionRequest();
$this->anet->setMerchantAuthentication($merchantAuthentication);
$this->merchant_authentication = new MerchantAuthenticationType();
$this->merchant_authentication->setName($this->company_gateway->getConfigField('apiLoginId'));
$this->merchant_authentication->setTransactionKey($this->company_gateway->getConfigField('transactionKey'));
return $this;
}
public function fire()
public function getPublicClientKey()
{
$request = new GetMerchantDetailsRequest();
$request->setMerchantAuthentication($this->merchant_authentication);
$controller = new GetMerchantDetailsController($request);
$response = $controller->executeWithApiResponse($this->mode());
return $response->getPublicClientKey();
}
private function mode()
{
if($this->company_gateway->getConfigField('testMode'))
$env = ANetEnvironment::SANDBOX;
else
$env = ANetEnvironment::PRODUCTION;
return ANetEnvironment::SANDBOX;
return $env = ANetEnvironment::PRODUCTION;
$controller = new CreateTransactionController($this->anet);
$response = $controller->executeWithApiResponse($env);
return $response;
}
public function authorizeView()
{
$data['gateway'] = $this->gateway;
$data['public_client_id'] = $this->init()->getPublicClientKey();
return render('gateways.authorize.add_credit_card', $data);
}
// public function fire()
// {
// $controller = new CreateTransactionController($this->anet);
// $response = $controller->executeWithApiResponse($env);
// return $response;
// }
public function authorize() {}

View File

@ -265,54 +265,68 @@ class RandomDataSeeder extends Seeder
]);
if (config('ninja.testvars.stripe')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
// if (config('ninja.testvars.stripe')) {
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.stripe'));
// $cg->save();
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.stripe'));
// $cg->save();
// }
// if (config('ninja.testvars.paypal')) {
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.paypal'));
// $cg->save();
// }
// if(config('ninja.testvars.checkout')) {
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.checkout'));
// $cg->save();
// }
if(config('ninja.testvars.authorize')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->gateway_key = '2f71dc17b0158ac30a7ae0839799e888';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
}
if (config('ninja.testvars.paypal')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.paypal'));
$cg->save();
}
if(config('ninja.testvars.checkout')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.checkout'));
$cg->config = encrypt(config('ninja.testvars.authorize'));
$cg->save();
}
}
}

View File

@ -9,8 +9,10 @@
*/
class AuthorizeAuthorizeCard {
constructor(key) {
this.key = key;
constructor(publicKey, loginId) {
this.publicKey = publicKey;
this.loginId = loginId;
this.cardHolderName = document.getElementById("cardholder_name");
this.cardButton = document.getElementById("card_button");
@ -19,8 +21,8 @@ class AuthorizeAuthorizeCard {
handleAuthorization() {
var authData = {};
authData.clientKey = this.key;
authData.apiLoginID = "YOUR API LOGIN ID";
authData.clientKey = this.publicKey;
authData.apiLoginID = this.loginId;
var cardData = {};
cardData.cardNumber = document.getElementById("card_number").value;
@ -77,5 +79,9 @@ const publicKey = document.querySelector(
'meta[name="authorize-public-key"]'
).content;
const loginId = document.querySelector(
'meta[name="api_login_id"]'
).content;
/** @handle */
new AuthorizeAuthorizeCard(publicKey).handle();
new AuthorizeAuthorizeCard(publicKey, loginId).handle();

View File

@ -2,7 +2,8 @@
@section('meta_title', ctrans('texts.add_credit_card'))
@push('head')
<meta name="authorize-public-key" content="{{ $gateway->getPublishableKey() }}">
<meta name="authorize-public-key" content="{{ $public_client_id }}">
<meta name="authorize-login-id" content="{{ $api_login_id }}">
@endpush
@section('body')