mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on Alipay
This commit is contained in:
parent
e6cad704ef
commit
e87f2def1d
@ -414,6 +414,7 @@ if (! defined('APP_NAME')) {
|
|||||||
define('GATEWAY_TYPE_BITCOIN', 4);
|
define('GATEWAY_TYPE_BITCOIN', 4);
|
||||||
define('GATEWAY_TYPE_DWOLLA', 5);
|
define('GATEWAY_TYPE_DWOLLA', 5);
|
||||||
define('GATEWAY_TYPE_CUSTOM', 6);
|
define('GATEWAY_TYPE_CUSTOM', 6);
|
||||||
|
define('GATEWAY_TYPE_ALIPAY', 7);
|
||||||
define('GATEWAY_TYPE_TOKEN', 'token');
|
define('GATEWAY_TYPE_TOKEN', 'token');
|
||||||
|
|
||||||
define('TEMPLATE_INVOICE', 'invoice');
|
define('TEMPLATE_INVOICE', 'invoice');
|
||||||
|
@ -130,6 +130,10 @@ class ClientPortalController extends BaseController
|
|||||||
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) {
|
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) {
|
||||||
$data['enableWePayACH'] = $wepayGateway->getAchEnabled();
|
$data['enableWePayACH'] = $wepayGateway->getAchEnabled();
|
||||||
}
|
}
|
||||||
|
if ($stripeGateway = $account->getGatewayConfig(GATEWAY_STRIPE)) {
|
||||||
|
//$data['enableStripeSources'] = $stripeGateway->getAlipayEnabled();
|
||||||
|
$data['enableStripeSources'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$showApprove = $invoice->quote_invoice_id ? false : true;
|
$showApprove = $invoice->quote_invoice_id ? false : true;
|
||||||
if ($invoice->due_date) {
|
if ($invoice->due_date) {
|
||||||
|
@ -198,6 +198,33 @@ class OnlinePaymentController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createSource($invitationKey, $gatewayType)
|
||||||
|
{
|
||||||
|
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
|
return response()->view('error', [
|
||||||
|
'error' => trans('texts.invoice_not_found'),
|
||||||
|
'hideHeader' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayType);
|
||||||
|
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
||||||
|
|
||||||
|
return $paymentDriver->createSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function completeSource($invitationKey, $gatewayType)
|
||||||
|
{
|
||||||
|
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
|
return response()->view('error', [
|
||||||
|
'error' => trans('texts.invoice_not_found'),
|
||||||
|
'hideHeader' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->to('view/' . $invitation->invitation_key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $paymentDriver
|
* @param $paymentDriver
|
||||||
* @param $exception
|
* @param $exception
|
||||||
|
@ -33,6 +33,8 @@ Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
|
|||||||
Route::get('approve/{invitation_key}', 'QuoteController@approve');
|
Route::get('approve/{invitation_key}', 'QuoteController@approve');
|
||||||
Route::get('payment/{invitation_key}/{gateway_type?}/{source_id?}', 'OnlinePaymentController@showPayment');
|
Route::get('payment/{invitation_key}/{gateway_type?}/{source_id?}', 'OnlinePaymentController@showPayment');
|
||||||
Route::post('payment/{invitation_key}', 'OnlinePaymentController@doPayment');
|
Route::post('payment/{invitation_key}', 'OnlinePaymentController@doPayment');
|
||||||
|
Route::get('create_source/{invitation_key}/{gateway_type}', 'OnlinePaymentController@createSource');
|
||||||
|
Route::get('complete_source/{invitation_key}/{gateway_type}', 'OnlinePaymentController@completeSource');
|
||||||
Route::match(['GET', 'POST'], 'complete/{invitation_key?}/{gateway_type?}', 'OnlinePaymentController@offsitePayment');
|
Route::match(['GET', 'POST'], 'complete/{invitation_key?}/{gateway_type?}', 'OnlinePaymentController@offsitePayment');
|
||||||
Route::get('bank/{routing_number}', 'OnlinePaymentController@getBankInfo');
|
Route::get('bank/{routing_number}', 'OnlinePaymentController@getBankInfo');
|
||||||
Route::get('client/payment_methods', 'ClientPortalController@paymentMethods');
|
Route::get('client/payment_methods', 'ClientPortalController@paymentMethods');
|
||||||
|
@ -67,7 +67,7 @@ class AccountGateway extends EntityModel
|
|||||||
$provider = str_replace('\\', '', $provider);
|
$provider = str_replace('\\', '', $provider);
|
||||||
$class = $folder . $provider . 'PaymentDriver';
|
$class = $folder . $provider . 'PaymentDriver';
|
||||||
$class = str_replace('_', '', $class);
|
$class = str_replace('_', '', $class);
|
||||||
|
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
return $class;
|
return $class;
|
||||||
} else {
|
} else {
|
||||||
@ -144,6 +144,18 @@ class AccountGateway extends EntityModel
|
|||||||
return ! empty($this->getConfigField('enableAch'));
|
return ! empty($this->getConfigField('enableAch'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getAlipayEnabled()
|
||||||
|
{
|
||||||
|
if (\Utils::isNinjaDev()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ! empty($this->getConfigField('enableAlipay'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Ninja\PaymentDrivers;
|
|||||||
|
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentMethod;
|
use App\Models\PaymentMethod;
|
||||||
|
use App\Models\GatewayType;
|
||||||
use Cache;
|
use Cache;
|
||||||
use Exception;
|
use Exception;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
@ -24,6 +25,10 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
$types[] = GATEWAY_TYPE_BANK_TRANSFER;
|
$types[] = GATEWAY_TYPE_BANK_TRANSFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->accountGateway && $this->accountGateway->getAlipayEnabled()) {
|
||||||
|
$types[] = GATEWAY_TYPE_ALIPAY;
|
||||||
|
}
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +313,23 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createSource()
|
||||||
|
{
|
||||||
|
$amount = intval($this->invoice()->getRequestedAmount() * 100);
|
||||||
|
$currency = $this->client()->getCurrencyCode();
|
||||||
|
$gatewayType = GatewayType::getAliasFromId($this->gatewayType);
|
||||||
|
$redirect = url("/complete_source/{$this->invitation->invitation_key}/{$gatewayType}");
|
||||||
|
$email = $this->contact()->email;
|
||||||
|
|
||||||
|
$data = "type=alipay&amount={$amount}¤cy={$currency}&redirect[return_url]={$redirect}&owner[email]={$email}";
|
||||||
|
$response = $this->makeStripeCall('POST', 'sources', $data);
|
||||||
|
|
||||||
|
$this->invitation->transaction_reference = $response['id'];
|
||||||
|
$this->invitation->save();
|
||||||
|
|
||||||
|
return redirect($response['redirect']['url']);
|
||||||
|
}
|
||||||
|
|
||||||
public function makeStripeCall($method, $url, $body = null)
|
public function makeStripeCall($method, $url, $body = null)
|
||||||
{
|
{
|
||||||
$apiKey = $this->accountGateway->getConfig()->apiKey;
|
$apiKey = $this->accountGateway->getConfig()->apiKey;
|
||||||
@ -347,6 +369,10 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
public function handleWebHook($input)
|
public function handleWebHook($input)
|
||||||
{
|
{
|
||||||
|
if (\Utils::isNinjaDev()) {
|
||||||
|
\Log::info("WEB HOOK: {$eventType} {$eventId}");
|
||||||
|
}
|
||||||
|
|
||||||
$eventId = array_get($input, 'id');
|
$eventId = array_get($input, 'id');
|
||||||
$eventType = array_get($input, 'type');
|
$eventType = array_get($input, 'type');
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class GatewayTypesSeeder extends Seeder
|
|||||||
['alias' => 'bitcoin', 'name' => 'Bitcoin'],
|
['alias' => 'bitcoin', 'name' => 'Bitcoin'],
|
||||||
['alias' => 'dwolla', 'name' => 'Dwolla'],
|
['alias' => 'dwolla', 'name' => 'Dwolla'],
|
||||||
['alias' => 'custom', 'name' => 'Custom'],
|
['alias' => 'custom', 'name' => 'Custom'],
|
||||||
|
['alias' => 'alipay', 'name' => 'Alipay'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($gateway_types as $gateway_type) {
|
foreach ($gateway_types as $gateway_type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user