mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 02:04:35 -04:00
Working on Authorize payment flow
This commit is contained in:
parent
790b3ff654
commit
7468813cd8
@ -130,7 +130,7 @@ class PaymentController extends Controller
|
|||||||
|
|
||||||
return $gateway
|
return $gateway
|
||||||
->driver(auth()->user()->client)
|
->driver(auth()->user()->client)
|
||||||
->setPaymentMethod('App\\PaymentDrivers\\Stripe\\Alipay')
|
->setPaymentMethod($request->input('payment_method_id'))
|
||||||
->processPaymentResponse($request);
|
->processPaymentResponse($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,10 @@ class StoreInvoiceRequest extends Request
|
|||||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
|
||||||
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($input['client_contacts'])) {
|
if (isset($input['client_contacts'])) {
|
||||||
foreach ($input['client_contacts'] as $key => $contact) {
|
foreach ($input['client_contacts'] as $key => $contact) {
|
||||||
if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) {
|
if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) {
|
||||||
|
@ -65,6 +65,10 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
|
||||||
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($input['invitations'])) {
|
if (isset($input['invitations'])) {
|
||||||
foreach ($input['invitations'] as $key => $value) {
|
foreach ($input['invitations'] as $key => $value) {
|
||||||
if (is_numeric($input['invitations'][$key]['id'])) {
|
if (is_numeric($input['invitations'][$key]['id'])) {
|
||||||
|
@ -99,6 +99,7 @@ class Invoice extends BaseModel
|
|||||||
'custom_surcharge_tax3',
|
'custom_surcharge_tax3',
|
||||||
'custom_surcharge_tax4',
|
'custom_surcharge_tax4',
|
||||||
'design_id',
|
'design_id',
|
||||||
|
'assigned_user_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
@ -20,4 +20,6 @@ abstract class AbstractPaymentDriver
|
|||||||
|
|
||||||
abstract public function refund($amount, $transaction_reference, $return_client_response = false);
|
abstract public function refund($amount, $transaction_reference, $return_client_response = false);
|
||||||
|
|
||||||
|
abstract public function bootPaymentMethod();
|
||||||
|
|
||||||
}
|
}
|
36
app/PaymentDrivers/Authorize/AuthorizeCreditCard.php
Normal file
36
app/PaymentDrivers/Authorize/AuthorizeCreditCard.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\PaymentDrivers\Authorize;
|
||||||
|
|
||||||
|
use App\PaymentDrivers\AuthorizePaymentDriver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BaseDriver
|
||||||
|
* @package App\PaymentDrivers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class AuthorizeCreditCard
|
||||||
|
{
|
||||||
|
public $authorize;
|
||||||
|
|
||||||
|
public function __construct(AuthorizePaymentDriver $authorize)
|
||||||
|
{
|
||||||
|
$this->authorize = $authorize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processPaymentView($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,19 @@ class AuthorizePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public $merchant_authentication;
|
public $merchant_authentication;
|
||||||
|
|
||||||
|
public static $methods = [
|
||||||
|
GatewayType::CREDIT_CARD => AuthorizeCreditCard::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function bootPaymentMethod()
|
||||||
|
{
|
||||||
|
|
||||||
|
$class = self::$methods[$this->getPaymentMethodId()];
|
||||||
|
|
||||||
|
$this->payment_method = new $class($this);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the gateway types
|
* Returns the gateway types
|
||||||
*/
|
*/
|
||||||
@ -97,6 +110,8 @@ class AuthorizePaymentDriver extends BaseDriver
|
|||||||
public function processPaymentView($data)
|
public function processPaymentView($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
return $this->bootPaymentMethod()->payment_method->processPaymentView($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processPaymentResponse($request)
|
public function processPaymentResponse($request)
|
||||||
|
@ -46,8 +46,13 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
/* The client */
|
/* The client */
|
||||||
public $client;
|
public $client;
|
||||||
|
|
||||||
|
/* The payment method id*/
|
||||||
|
public $payment_method_id;
|
||||||
|
|
||||||
public $payment_method;
|
public $payment_method;
|
||||||
|
|
||||||
|
public $methods = [];
|
||||||
|
|
||||||
public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false)
|
public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false)
|
||||||
{
|
{
|
||||||
$this->company_gateway = $company_gateway;
|
$this->company_gateway = $company_gateway;
|
||||||
@ -85,14 +90,21 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
*/
|
*/
|
||||||
public function refund($amount, $transaction_reference, $return_client_response = false) {}
|
public function refund($amount, $transaction_reference, $return_client_response = false) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes an instance of the payment method
|
||||||
|
* @return object The payment method instance
|
||||||
|
*/
|
||||||
|
public function bootPaymentMethod() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the inbound request payment method type for access.
|
* Set the inbound request payment method type for access.
|
||||||
*
|
*
|
||||||
* @param int $payment_method_id The Payment Method ID
|
* @param int $payment_method_id The Payment Method ID
|
||||||
*/
|
*/
|
||||||
public function setPaymentMethod($payment_method_id)
|
public function setPaymentMethod($method_id)
|
||||||
{
|
{
|
||||||
$this->payment_method = $payment_method_id;
|
$this->payment_method_id = $payment_method_id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,46 +31,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<dl>
|
<dl>
|
||||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
|
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
|
@include('portal.ninja2020.gateways.authorize.credit_card')
|
||||||
{{ ctrans('texts.name') }}
|
|
||||||
</dt>
|
|
||||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
<input class="input w-full" id="cardholder_name" type="text" placeholder="{{ ctrans('texts.name') }}">
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
|
||||||
{{ ctrans('texts.credit_card') }}
|
|
||||||
</dt>
|
|
||||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
<input class="input w-full" id="card_number" type="text" placeholder="{{ ctrans('texts.card_number') }}">
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
|
||||||
{{ ctrans('texts.expiration_month') }}
|
|
||||||
</dt>
|
|
||||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
<input class="input w-full" id="expiration_month" type="text" placeholder="{{ ctrans('texts.expiration_month') }}">
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
|
||||||
{{ ctrans('texts.expiration_year') }}
|
|
||||||
</dt>
|
|
||||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
<input class="input w-full" id="expiration_year" type="text" placeholder="{{ ctrans('texts.expiration_year') }}">
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
|
||||||
{{ ctrans('texts.cvv') }}
|
|
||||||
</dt>
|
|
||||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
<input class="input w-full" id="cvv" type="text" placeholder="{{ ctrans('texts.cvv') }}">
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
<dt class="text-sm leading-5 font-medium text-gray-500">
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
{{ ctrans('texts.save_as_default') }}
|
{{ ctrans('texts.save_as_default') }}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
|
||||||
|
{{ ctrans('texts.name') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="cardholder_name" type="text" placeholder="{{ ctrans('texts.name') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.credit_card') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="card_number" type="text" placeholder="{{ ctrans('texts.card_number') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.expiration_month') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="expiration_month" type="text" placeholder="{{ ctrans('texts.expiration_month') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.expiration_year') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="expiration_year" type="text" placeholder="{{ ctrans('texts.expiration_year') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.cvv') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="cvv" type="text" placeholder="{{ ctrans('texts.cvv') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user