Authorize.net payment via credit card

This commit is contained in:
David Bomba 2020-06-16 13:49:45 +10:00
parent 2648690b48
commit b85b0913a6
4 changed files with 20 additions and 10 deletions

View File

@ -32,14 +32,16 @@ class AuthorizeCreditCard
public function processPaymentView($data)
{
$tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id)
->where('company_gateway_key', $this->authorize->company_gateway->gateway_key)
->where('company_gateway_id', $this->authorize->company_gateway->id)
->where('gateway_type_id', $this->authorize->payment_method_id)
->get();
$data['tokens'] = $tokens;
$data['gateway'] = $this->authorize->company_gateway;
$data['public_client_id'] = $this->authorize->init()->getPublicClientKey();
$data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId');
return render('portal.ninja202.gateways.authorize.credit_card_payment', $data);
return render('gateways.authorize.credit_card_payment', $data);
}
}

View File

@ -38,9 +38,9 @@ class AuthorizePaymentDriver extends BaseDriver
];
public function bootPaymentMethod()
{
{info(print_r($this->getPaymentMethod(),1));
$class = self::$methods[$this->getPaymentMethodId()];
$class = self::$methods[$this->getPaymentMethod()];
$this->payment_method = new $class($this);

View File

@ -51,7 +51,7 @@ class BaseDriver extends AbstractPaymentDriver
public $payment_method;
public $methods = [];
public static $methods = [];
public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false)
{
@ -101,8 +101,10 @@ class BaseDriver extends AbstractPaymentDriver
*
* @param int $payment_method_id The Payment Method ID
*/
public function setPaymentMethod($method_id)
public function setPaymentMethod($payment_method_id)
{
info("setting payment method {$payment_method_id}");
$this->payment_method_id = $payment_method_id;
return $this;
@ -115,6 +117,6 @@ class BaseDriver extends AbstractPaymentDriver
*/
public function getPaymentMethod()
{
return $this->payment_method;
return $this->payment_method_id;
}
}

View File

@ -15,6 +15,8 @@
<input type="hidden" name="is_default" id="is_default">
<input type="hidden" name="dataValue" id="dataValue" />
<input type="hidden" name="dataDescriptor" id="dataDescriptor" />
<input type="hidden" name="token" id="token" />
<input type="hidden" name="save_method" id="save_method" />
</form>
<div class="container mx-auto">
<div class="grid grid-cols-6 gap-4">
@ -38,15 +40,19 @@
</dd>
</div>
<div class="bg-white px-4 py-5 flex justify-end">
<button type="primary" id="card_button">{{ ctrans('texts.add_payment_method') }}</button>
<button type="primary" id="card_button">{{ ctrans('texts.pay_now') }}</button>
</div>
</dl>
@else
<!-- TODO Iterate through the tokens and display the card type and last4 and present
a button for payment -->
<ul>
@foreach($tokens as $token)
<li>
$token->meta->brand : $token->meta->last4 : <button class="primary" id="{{ $token->token }}">{{ ctrans('texts.pay_now') }}</button>
</li>
@endforeach
</ul>
@endif
</div>
</div>