mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-18 09:04:35 +01:00
Updated payment logic with config settings.
This commit is contained in:
parent
d20f6d3055
commit
5bd1aff573
@ -121,8 +121,6 @@ class AccountController extends \BaseController {
|
||||
'data-newRow' => $newRow
|
||||
);
|
||||
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
$data = [
|
||||
@ -138,14 +136,8 @@ class AccountController extends \BaseController {
|
||||
foreach ($data['gateways'] as $gateway)
|
||||
{
|
||||
$paymentLibrary = $gateway->paymentlibrary;
|
||||
|
||||
if($paymentLibrary->name == 'Omnipay')
|
||||
{
|
||||
$gateway->fields = Omnipay::create($gateway->provider)->getDefaultParameters();
|
||||
}
|
||||
else {
|
||||
$gateway->fields = array();
|
||||
}
|
||||
|
||||
$gateway->fields = $gateway->getFields();
|
||||
|
||||
if ($accountGateway && $accountGateway->gateway_id == $gateway->id)
|
||||
{
|
||||
@ -471,7 +463,10 @@ class AccountController extends \BaseController {
|
||||
if ($gatewayId = Input::get('gateway_id'))
|
||||
{
|
||||
$gateway = Gateway::findOrFail($gatewayId);
|
||||
$fields = Omnipay::create($gateway->provider)->getDefaultParameters();
|
||||
|
||||
$paymentLibrary = $gateway->paymentlibrary;
|
||||
|
||||
$fields = $gateway->getFields();
|
||||
|
||||
foreach ($fields as $field => $details)
|
||||
{
|
||||
|
@ -174,8 +174,8 @@ class PaymentController extends \BaseController
|
||||
'ship_to_state' => $input['state'],
|
||||
'ship_to_postal_code' => $input['postal_code'],
|
||||
'currency_code' => $invoice->client->currency->code,
|
||||
'returnUrl' => URL::to('complete'),
|
||||
'cancelUrl' => URL::to('/')
|
||||
'returnUrl' => URL::to('complete'),
|
||||
'cancelUrl' => URL::to('/')
|
||||
];
|
||||
|
||||
Session::put($key, $data);
|
||||
@ -190,15 +190,22 @@ class PaymentController extends \BaseController
|
||||
$data = [];
|
||||
}
|
||||
|
||||
$card = new CreditCard($data);
|
||||
|
||||
return [
|
||||
'amount' => $invoice->amount,
|
||||
'card' => $card,
|
||||
'currency' => $invoice->client->currency->code,
|
||||
'returnUrl' => URL::to('complete'),
|
||||
'cancelUrl' => URL::to('/')
|
||||
];
|
||||
if($paymentLibrary->name == "Omnipay")
|
||||
{
|
||||
$card = new CreditCard($data);
|
||||
|
||||
return [
|
||||
'amount' => $invoice->amount,
|
||||
'card' => $card,
|
||||
'currency' => $invoice->client->currency->code,
|
||||
'returnUrl' => URL::to('complete'),
|
||||
'cancelUrl' => URL::to('/')
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function show_payment($invitationKey)
|
||||
@ -320,14 +327,13 @@ class PaymentController extends \BaseController
|
||||
}
|
||||
else if ($input && $paymentLibrary->name == "PHP-Payments")
|
||||
{
|
||||
$provider = $accountGateway->gateway->provider;
|
||||
$p = new PHP_Payments;
|
||||
|
||||
$config = Payment_Utility::load('config', '/path/to/your/gateway/config');
|
||||
$config = Payment_Utility::load('config', 'drivers/'.$provider);
|
||||
$details = self::getPaymentDetails($invoice, Input::all());
|
||||
|
||||
|
||||
|
||||
$response = $p->oneoff_payment('name_of_payment_driver', $details, $config);
|
||||
$response = $p->oneoff_payment($provider, $details, $config);
|
||||
|
||||
if ($response->status == 'Success')
|
||||
{
|
||||
@ -341,17 +347,10 @@ $response = $p->oneoff_payment('name_of_payment_driver', $details, $config);
|
||||
Session::flash('message', 'Successfully applied payment');
|
||||
return Redirect::to('view/' . $payment->invitation->invitation_key);
|
||||
}
|
||||
else if ($response->isRedirect())
|
||||
{
|
||||
$invitation->transaction_reference = $ref;
|
||||
$invitation->save();
|
||||
|
||||
$response->redirect();
|
||||
}
|
||||
else
|
||||
{
|
||||
Session::flash('error', $response->getMessage());
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
|
||||
Session::flash('error', $response->details);
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,10 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
{
|
||||
$gateways = [
|
||||
array('name'=>'BeanStream', 'provider'=>'BeanStream', 'payment_library_id' => 2),
|
||||
array('name'=>'iTransact', 'provider'=>'iTransact', 'payment_library_id' => 2),
|
||||
array('name'=>'Amazon_Simplepay', 'provider'=>'Amazon Simplepay', 'payment_library_id' => 2),
|
||||
array('name'=>'Amazon Simplepay', 'provider'=>'Amazon_Simplepay', 'payment_library_id' => 2),
|
||||
array('name'=>'Bluepay', 'provider'=>'Bluepay', 'payment_library_id' => 2),
|
||||
array('name'=>'Braintree', 'provider'=>'Braintree', 'payment_library_id' => 2),
|
||||
array('name'=>'Google_Checkout', 'provider'=>'Google Checkout', 'payment_library_id' => 2),
|
||||
array('name'=>'Google Checkout', 'provider'=>'Google_Checkout', 'payment_library_id' => 2),
|
||||
array('name'=>'Psigate', 'provider'=>'Psigate', 'payment_library_id' => 2),
|
||||
array('name'=>'Quickbooksms', 'provider'=>'Quickbooksms', 'payment_library_id' => 2)
|
||||
];
|
||||
@ -34,7 +33,6 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
|
||||
Gateway::where('provider', '=', 'AuthorizeNet_AIM')->update(array('sort_order' => 5, 'site_url' => 'http://www.authorize.net/'));
|
||||
Gateway::where('provider', '=', 'BeanStream')->update(array('sort_order' => 10, 'site_url' => 'http://www.beanstream.com/'));
|
||||
Gateway::where('provider', '=', 'iTransact')->update(array('sort_order' => 15, 'site_url' => 'http://itransact.com/'));
|
||||
Gateway::where('provider', '=', 'FirstData_Connect')->update(array('sort_order' => 20, 'site_url' => 'https://www.firstdata.com/'));
|
||||
Gateway::where('provider', '=', 'PayPal_Pro')->update(array('sort_order' => 25, 'site_url' => 'https://www.paypal.com/'));
|
||||
Gateway::where('provider', '=', 'TwoCheckout')->update(array('sort_order' => 30, 'site_url' => 'https://www.2checkout.com/'));
|
||||
|
@ -14,4 +14,25 @@ class Gateway extends Eloquent
|
||||
{
|
||||
return '/images/gateways/logo_'.$this->provider.'.png';
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
$paymentLibrary = $this->paymentlibrary;
|
||||
|
||||
if($paymentLibrary->name == 'Omnipay')
|
||||
{
|
||||
$fields = Omnipay::create($this->provider)->getDefaultParameters();
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields = Payment_Utility::load('config', 'drivers/'.$this->provider);
|
||||
}
|
||||
|
||||
if($fields == null)
|
||||
{
|
||||
$fields = array();
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
@ -12,12 +12,12 @@
|
||||
{{ Former::legend('Payment Gateway') }}
|
||||
|
||||
{{Former::label('Lorem Ipsum goes here.')}}
|
||||
|
||||
<div class="two-column">
|
||||
{{ Former::radios('recommendedGateway_id')
|
||||
->label('Recommended Gateways')
|
||||
->radios($recommendedGateways)
|
||||
->class('recommended-gateway')}}
|
||||
|
||||
</div>
|
||||
|
||||
@if ($accountGateway)
|
||||
{{ Former::populateField('gateway_id', $accountGateway->gateway_id) }}
|
||||
@ -63,8 +63,16 @@
|
||||
|
||||
function setFieldsShown() {
|
||||
var val = $('#gateway_id').val();
|
||||
var activeElement = $('.recommended-gateway[value=' + val + ']');
|
||||
var recommendedRadios = $('#recommendedGateway_id');
|
||||
|
||||
$('.gateway-fields').hide();
|
||||
$('#gateway_' + val + '_div').show();
|
||||
|
||||
if(activeElement && !activeElement.attr('checked'))
|
||||
{
|
||||
activeElement.attr('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user