1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Added support for an additional payment gateway (paypal + credit card)

This commit is contained in:
Hillel Coren 2015-03-04 10:27:23 +02:00
parent 5853dd34de
commit 10bc43df91
3 changed files with 6 additions and 9 deletions

View File

@ -137,11 +137,9 @@ class AccountGatewayController extends BaseController
if (count($currentGateways) > 0) { if (count($currentGateways) > 0) {
$currentGateway = $currentGateways[0]; $currentGateway = $currentGateways[0];
if ($currentGateway->isPayPal()) { if ($currentGateway->isPayPal()) {
$gateways->where('id', '!=', GATEWAY_PAYPAL_EXPRESS) $gateways->where('id', '!=', GATEWAY_PAYPAL_EXPRESS);
->where('id', '!=', GATEWAY_PAYPAL_PRO);
} else { } else {
$gateways->where('id', '>=', GATEWAY_PAYPAL_EXPRESS) $gateways->where('id', '=', GATEWAY_PAYPAL_EXPRESS);
->where('id', '<=', GATEWAY_PAYPAL_PRO);
$onlyPayPal = true; $onlyPayPal = true;
} }
} }

View File

@ -304,11 +304,10 @@ class PaymentController extends \BaseController
if (Input::has('use_paypal')) { if (Input::has('use_paypal')) {
Session::put('payment_type', Input::get('use_paypal') == 'true' ? PAYMENT_TYPE_PAYPAL : PAYMENT_TYPE_CREDIT_CARD); Session::put('payment_type', Input::get('use_paypal') == 'true' ? PAYMENT_TYPE_PAYPAL : PAYMENT_TYPE_CREDIT_CARD);
} else { } elseif (!Session::has('payment_type')) {
Session::put('payment_type', PAYMENT_TYPE_ANY); Session::put('payment_type', PAYMENT_TYPE_ANY);
} }
Session::save();
// For PayPal we redirect straight to their site // For PayPal we redirect straight to their site
$usePayPal = false; $usePayPal = false;
if ($usePayPal = Input::get('use_paypal')) { if ($usePayPal = Input::get('use_paypal')) {
@ -316,7 +315,7 @@ class PaymentController extends \BaseController
} else { } else {
$invitation = Invitation::with('invoice.client.account', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail(); $invitation = Invitation::with('invoice.client.account', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$account = $invitation->invoice->client->account; $account = $invitation->invoice->client->account;
if ($account->getGatewayByType(PAYMENT_TYPE_PAYPAL)) { if (count($account->account_gateways) == 1 && $account->getGatewayByType(PAYMENT_TYPE_PAYPAL)) {
$usePayPal = true; $usePayPal = true;
} }
} }
@ -607,6 +606,7 @@ class PaymentController extends \BaseController
$invitation->transaction_reference = $ref; $invitation->transaction_reference = $ref;
$invitation->save(); $invitation->save();
Session::save();
$response->redirect(); $response->redirect();
} else { } else {
Session::flash('error', $response->getMessage()); Session::flash('error', $response->getMessage());

View File

@ -22,7 +22,6 @@ class AccountGateway extends EntityModel
} }
public function isPayPal() { public function isPayPal() {
//return $this->gateway_id == GATEWAY_PAYPAL_EXPRESS || $this->gateway_id == GATEWAY_PAYPAL_PRO;
return $this->gateway_id == GATEWAY_PAYPAL_EXPRESS; return $this->gateway_id == GATEWAY_PAYPAL_EXPRESS;
} }
} }