mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:17:32 -05:00 
			
		
		
		
	Manually merging PR #630
This commit is contained in:
		
							parent
							
								
									cbe2b2905e
								
							
						
					
					
						commit
						89ff1be14f
					
				@ -84,6 +84,7 @@ class AccountGatewayController extends BaseController
 | 
				
			|||||||
        $data['selectGateways'] = Gateway::where('payment_library_id', '=', 1)
 | 
					        $data['selectGateways'] = Gateway::where('payment_library_id', '=', 1)
 | 
				
			||||||
                                    ->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)
 | 
					                                    ->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)
 | 
				
			||||||
                                    ->where('id', '!=', GATEWAY_BITPAY)
 | 
					                                    ->where('id', '!=', GATEWAY_BITPAY)
 | 
				
			||||||
 | 
					                                    ->where('id', '!=', GATEWAY_GOCARDLESS)
 | 
				
			||||||
                                    ->where('id', '!=', GATEWAY_DWOLLA)
 | 
					                                    ->where('id', '!=', GATEWAY_DWOLLA)
 | 
				
			||||||
                                    ->orderBy('name')->get();
 | 
					                                    ->orderBy('name')->get();
 | 
				
			||||||
        $data['hiddenFields'] = Gateway::$hiddenFields;
 | 
					        $data['hiddenFields'] = Gateway::$hiddenFields;
 | 
				
			||||||
@ -104,6 +105,9 @@ class AccountGatewayController extends BaseController
 | 
				
			|||||||
                if ($type == PAYMENT_TYPE_BITCOIN) {
 | 
					                if ($type == PAYMENT_TYPE_BITCOIN) {
 | 
				
			||||||
                    $paymentTypes[$type] .= ' - BitPay';
 | 
					                    $paymentTypes[$type] .= ' - BitPay';
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if ($type == PAYMENT_TYPE_DIRECT_DEBIT) {
 | 
				
			||||||
 | 
					                    $paymentTypes[$type] .= ' - GoCardless';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -173,6 +177,8 @@ class AccountGatewayController extends BaseController
 | 
				
			|||||||
            $gatewayId = GATEWAY_PAYPAL_EXPRESS;
 | 
					            $gatewayId = GATEWAY_PAYPAL_EXPRESS;
 | 
				
			||||||
        } elseif ($paymentType == PAYMENT_TYPE_BITCOIN) {
 | 
					        } elseif ($paymentType == PAYMENT_TYPE_BITCOIN) {
 | 
				
			||||||
            $gatewayId = GATEWAY_BITPAY;
 | 
					            $gatewayId = GATEWAY_BITPAY;
 | 
				
			||||||
 | 
					        } elseif ($paymentType == PAYMENT_TYPE_DIRECT_DEBIT) {
 | 
				
			||||||
 | 
					            $gatewayId = GATEWAY_GOCARDLESS;
 | 
				
			||||||
        } elseif ($paymentType == PAYMENT_TYPE_DWOLLA) {
 | 
					        } elseif ($paymentType == PAYMENT_TYPE_DWOLLA) {
 | 
				
			||||||
            $gatewayId = GATEWAY_DWOLLA;
 | 
					            $gatewayId = GATEWAY_DWOLLA;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -125,6 +125,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function show_payment($invitationKey, $paymentType = false)
 | 
					    public function show_payment($invitationKey, $paymentType = false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
 | 
					        $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
 | 
				
			||||||
        $invoice = $invitation->invoice;
 | 
					        $invoice = $invitation->invoice;
 | 
				
			||||||
        $client = $invoice->client;
 | 
					        $client = $invoice->client;
 | 
				
			||||||
@ -137,6 +138,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
            $paymentType = Session::get($invitation->id . 'payment_type') ?:
 | 
					            $paymentType = Session::get($invitation->id . 'payment_type') ?:
 | 
				
			||||||
                                $account->account_gateways[0]->getPaymentType();
 | 
					                                $account->account_gateways[0]->getPaymentType();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($paymentType == PAYMENT_TYPE_TOKEN) {
 | 
					        if ($paymentType == PAYMENT_TYPE_TOKEN) {
 | 
				
			||||||
            $useToken = true;
 | 
					            $useToken = true;
 | 
				
			||||||
            $paymentType = PAYMENT_TYPE_CREDIT_CARD;
 | 
					            $paymentType = PAYMENT_TYPE_CREDIT_CARD;
 | 
				
			||||||
@ -145,8 +147,10 @@ class PaymentController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $accountGateway = $invoice->client->account->getGatewayByType($paymentType);
 | 
					        $accountGateway = $invoice->client->account->getGatewayByType($paymentType);
 | 
				
			||||||
        $gateway = $accountGateway->gateway;
 | 
					        $gateway = $accountGateway->gateway;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
 | 
					        $acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Handle offsite payments
 | 
					        // Handle offsite payments
 | 
				
			||||||
        if ($useToken || $paymentType != PAYMENT_TYPE_CREDIT_CARD
 | 
					        if ($useToken || $paymentType != PAYMENT_TYPE_CREDIT_CARD
 | 
				
			||||||
            || $gateway->id == GATEWAY_EWAY
 | 
					            || $gateway->id == GATEWAY_EWAY
 | 
				
			||||||
@ -353,6 +357,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
        $account = $client->account;
 | 
					        $account = $client->account;
 | 
				
			||||||
        $accountGateway = $account->getGatewayByType(Session::get($invitation->id . 'payment_type'));
 | 
					        $accountGateway = $account->getGatewayByType(Session::get($invitation->id . 'payment_type'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules = [
 | 
					        $rules = [
 | 
				
			||||||
            'first_name' => 'required',
 | 
					            'first_name' => 'required',
 | 
				
			||||||
            'last_name' => 'required',
 | 
					            'last_name' => 'required',
 | 
				
			||||||
@ -434,12 +439,15 @@ class PaymentController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $response = $gateway->purchase($details)->send();
 | 
					            $response = $gateway->purchase($details)->send();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($accountGateway->gateway_id == GATEWAY_EWAY) {
 | 
					            if ($accountGateway->gateway_id == GATEWAY_EWAY) {
 | 
				
			||||||
                $ref = $response->getData()['AccessCode'];
 | 
					                $ref = $response->getData()['AccessCode'];
 | 
				
			||||||
            } elseif ($accountGateway->gateway_id == GATEWAY_TWO_CHECKOUT) {
 | 
					            } elseif ($accountGateway->gateway_id == GATEWAY_TWO_CHECKOUT) {
 | 
				
			||||||
                $ref = $response->getData()['cart_order_id'];
 | 
					                $ref = $response->getData()['cart_order_id'];
 | 
				
			||||||
            } elseif ($accountGateway->gateway_id == GATEWAY_PAYFAST) {
 | 
					            } elseif ($accountGateway->gateway_id == GATEWAY_PAYFAST) {
 | 
				
			||||||
                $ref = $response->getData()['m_payment_id'];
 | 
					                $ref = $response->getData()['m_payment_id'];
 | 
				
			||||||
 | 
					            } elseif ($accountGateway->gateway_id == GATEWAY_GOCARDLESS) {
 | 
				
			||||||
 | 
					                $ref = $response->getData()['signature'];
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                $ref = $response->getTransactionReference();
 | 
					                $ref = $response->getTransactionReference();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -466,6 +474,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                return Redirect::to('view/'.$payment->invitation->invitation_key);
 | 
					                return Redirect::to('view/'.$payment->invitation->invitation_key);
 | 
				
			||||||
            } elseif ($response->isRedirect()) {
 | 
					            } elseif ($response->isRedirect()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $invitation->transaction_reference = $ref;
 | 
					                $invitation->transaction_reference = $ref;
 | 
				
			||||||
                $invitation->save();
 | 
					                $invitation->save();
 | 
				
			||||||
                Session::put('transaction_reference', $ref);
 | 
					                Session::put('transaction_reference', $ref);
 | 
				
			||||||
@ -515,7 +524,6 @@ class PaymentController extends BaseController
 | 
				
			|||||||
            $this->error('No-Payment-Type', false, false);
 | 
					            $this->error('No-Payment-Type', false, false);
 | 
				
			||||||
            return Redirect::to($invitation->getLink());
 | 
					            return Redirect::to($invitation->getLink());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $accountGateway = $account->getGatewayByType($paymentType);
 | 
					        $accountGateway = $account->getGatewayByType($paymentType);
 | 
				
			||||||
        $gateway = $this->paymentService->createGateway($accountGateway);
 | 
					        $gateway = $this->paymentService->createGateway($accountGateway);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -535,7 +543,9 @@ class PaymentController extends BaseController
 | 
				
			|||||||
                && !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)
 | 
					                && !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)
 | 
				
			||||||
                && !$accountGateway->isGateway(GATEWAY_CHECKOUT_COM)) {
 | 
					                && !$accountGateway->isGateway(GATEWAY_CHECKOUT_COM)) {
 | 
				
			||||||
                $details = $this->paymentService->getPaymentDetails($invitation, $accountGateway);
 | 
					                $details = $this->paymentService->getPaymentDetails($invitation, $accountGateway);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $response = $this->paymentService->completePurchase($gateway, $accountGateway, $details, $token);
 | 
					                $response = $this->paymentService->completePurchase($gateway, $accountGateway, $details, $token);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $ref = $response->getTransactionReference() ?: $token;
 | 
					                $ref = $response->getTransactionReference() ?: $token;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ($response->isCancelled()) {
 | 
					                if ($response->isCancelled()) {
 | 
				
			||||||
@ -554,6 +564,7 @@ class PaymentController extends BaseController
 | 
				
			|||||||
                return Redirect::to($invitation->getLink());
 | 
					                return Redirect::to($invitation->getLink());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->error('Offsite-uncaught', false, $accountGateway, $e);
 | 
					            $this->error('Offsite-uncaught', false, $accountGateway, $e);
 | 
				
			||||||
            return Redirect::to($invitation->getLink());
 | 
					            return Redirect::to($invitation->getLink());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -417,6 +417,7 @@ if (!defined('CONTACT_EMAIL')) {
 | 
				
			|||||||
    define('GATEWAY_PAYPAL_EXPRESS', 17);
 | 
					    define('GATEWAY_PAYPAL_EXPRESS', 17);
 | 
				
			||||||
    define('GATEWAY_PAYPAL_PRO', 18);
 | 
					    define('GATEWAY_PAYPAL_PRO', 18);
 | 
				
			||||||
    define('GATEWAY_STRIPE', 23);
 | 
					    define('GATEWAY_STRIPE', 23);
 | 
				
			||||||
 | 
					    define('GATEWAY_GOCARDLESS', 6);
 | 
				
			||||||
    define('GATEWAY_TWO_CHECKOUT', 27);
 | 
					    define('GATEWAY_TWO_CHECKOUT', 27);
 | 
				
			||||||
    define('GATEWAY_BEANSTREAM', 29);
 | 
					    define('GATEWAY_BEANSTREAM', 29);
 | 
				
			||||||
    define('GATEWAY_PSIGATE', 30);
 | 
					    define('GATEWAY_PSIGATE', 30);
 | 
				
			||||||
@ -484,6 +485,7 @@ if (!defined('CONTACT_EMAIL')) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    define('PAYMENT_TYPE_PAYPAL', 'PAYMENT_TYPE_PAYPAL');
 | 
					    define('PAYMENT_TYPE_PAYPAL', 'PAYMENT_TYPE_PAYPAL');
 | 
				
			||||||
    define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
 | 
					    define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
 | 
				
			||||||
 | 
					    define('PAYMENT_TYPE_DIRECT_DEBIT', 'PAYMENT_TYPE_DIRECT_DEBIT');
 | 
				
			||||||
    define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN');
 | 
					    define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN');
 | 
				
			||||||
    define('PAYMENT_TYPE_DWOLLA', 'PAYMENT_TYPE_DWOLLA');
 | 
					    define('PAYMENT_TYPE_DWOLLA', 'PAYMENT_TYPE_DWOLLA');
 | 
				
			||||||
    define('PAYMENT_TYPE_TOKEN', 'PAYMENT_TYPE_TOKEN');
 | 
					    define('PAYMENT_TYPE_TOKEN', 'PAYMENT_TYPE_TOKEN');
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,8 @@ class Gateway extends Eloquent
 | 
				
			|||||||
        PAYMENT_TYPE_CREDIT_CARD,
 | 
					        PAYMENT_TYPE_CREDIT_CARD,
 | 
				
			||||||
        PAYMENT_TYPE_PAYPAL,
 | 
					        PAYMENT_TYPE_PAYPAL,
 | 
				
			||||||
        PAYMENT_TYPE_BITCOIN,
 | 
					        PAYMENT_TYPE_BITCOIN,
 | 
				
			||||||
        PAYMENT_TYPE_DWOLLA
 | 
					        PAYMENT_TYPE_DIRECT_DEBIT,
 | 
				
			||||||
 | 
					        PAYMENT_TYPE_DWOLLA,
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static $hiddenFields = [
 | 
					    public static $hiddenFields = [
 | 
				
			||||||
@ -94,6 +95,8 @@ class Gateway extends Eloquent
 | 
				
			|||||||
            return PAYMENT_TYPE_BITCOIN;
 | 
					            return PAYMENT_TYPE_BITCOIN;
 | 
				
			||||||
        } else if ($gatewayId == GATEWAY_DWOLLA) {
 | 
					        } else if ($gatewayId == GATEWAY_DWOLLA) {
 | 
				
			||||||
            return PAYMENT_TYPE_DWOLLA;
 | 
					            return PAYMENT_TYPE_DWOLLA;
 | 
				
			||||||
 | 
					        }else if ($gatewayId == GATEWAY_GOCARDLESS) {
 | 
				
			||||||
 | 
					            return PAYMENT_TYPE_DIRECT_DEBIT;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return PAYMENT_TYPE_CREDIT_CARD;
 | 
					            return PAYMENT_TYPE_CREDIT_CARD;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -254,6 +254,7 @@ class PaymentService extends BaseService
 | 
				
			|||||||
            $response = $gateway->fetchTransaction($details)->send();
 | 
					            $response = $gateway->fetchTransaction($details)->send();
 | 
				
			||||||
            return $gateway->fetchTransaction($details)->send();
 | 
					            return $gateway->fetchTransaction($details)->send();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $gateway->completePurchase($details)->send();
 | 
					            return $gateway->completePurchase($details)->send();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -593,6 +593,7 @@ return array(
 | 
				
			|||||||
    'payment_type_credit_card' => 'Credit Card',
 | 
					    'payment_type_credit_card' => 'Credit Card',
 | 
				
			||||||
    'payment_type_paypal' => 'PayPal',
 | 
					    'payment_type_paypal' => 'PayPal',
 | 
				
			||||||
    'payment_type_bitcoin' => 'Bitcoin',
 | 
					    'payment_type_bitcoin' => 'Bitcoin',
 | 
				
			||||||
 | 
					    'payment_type_direct_debit' => 'Direct Debit',
 | 
				
			||||||
    'knowledge_base' => 'Knowledge Base',
 | 
					    'knowledge_base' => 'Knowledge Base',
 | 
				
			||||||
    'partial' => 'Partial',
 | 
					    'partial' => 'Partial',
 | 
				
			||||||
    'partial_remaining' => ':partial of :balance',
 | 
					    'partial_remaining' => ':partial of :balance',
 | 
				
			||||||
 | 
				
			|||||||
@ -134,6 +134,8 @@
 | 
				
			|||||||
                setFieldsShown({{ GATEWAY_PAYPAL_EXPRESS }});
 | 
					                setFieldsShown({{ GATEWAY_PAYPAL_EXPRESS }});
 | 
				
			||||||
            } else if (val == 'PAYMENT_TYPE_DWOLLA') {
 | 
					            } else if (val == 'PAYMENT_TYPE_DWOLLA') {
 | 
				
			||||||
                setFieldsShown({{ GATEWAY_DWOLLA }});
 | 
					                setFieldsShown({{ GATEWAY_DWOLLA }});
 | 
				
			||||||
 | 
					            } else if (val == 'PAYMENT_TYPE_DIRECT_DEBIT') {
 | 
				
			||||||
 | 
					                setFieldsShown({{ GATEWAY_GOCARDLESS }});
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                setFieldsShown({{ GATEWAY_BITPAY }});
 | 
					                setFieldsShown({{ GATEWAY_BITPAY }});
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user