From 7150a148af7d8a5e823f5dea637e1c3cf8727722 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 21 Oct 2015 07:30:23 +0300 Subject: [PATCH] Added PayPal buttonsource --- app/Http/Controllers/PaymentController.php | 6 +++--- app/Services/PaymentService.php | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 00d787d6a0..84a1405518 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -419,7 +419,7 @@ class PaymentController extends BaseController } $gateway = $this->paymentService->createGateway($accountGateway); - $details = $this->paymentService->getPaymentDetails($invitation, $data); + $details = $this->paymentService->getPaymentDetails($invitation, $accountGateway, $data); // check if we're creating/using a billing token if ($accountGateway->gateway_id == GATEWAY_STRIPE) { @@ -437,7 +437,7 @@ class PaymentController extends BaseController } $response = $gateway->purchase($details)->send(); - + if ($accountGateway->gateway_id == GATEWAY_EWAY) { $ref = $response->getData()['AccessCode']; } elseif ($accountGateway->gateway_id == GATEWAY_TWO_CHECKOUT) { @@ -515,7 +515,7 @@ class PaymentController extends BaseController try { if (method_exists($gateway, 'completePurchase') && !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)) { - $details = $this->paymentService->getPaymentDetails($invitation); + $details = $this->paymentService->getPaymentDetails($invitation, $accountGateway); $response = $gateway->completePurchase($details)->send(); $ref = $response->getTransactionReference(); diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 3d82cd4d39..365f140c0f 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -36,7 +36,7 @@ class PaymentService { $gateway->$function($val); } - if ($accountGateway->gateway->id == GATEWAY_DWOLLA) { + if ($accountGateway->isGateway(GATEWAY_DWOLLA)) { if ($gateway->getSandbox() && isset($_ENV['DWOLLA_SANDBOX_KEY']) && isset($_ENV['DWOLLA_SANSBOX_SECRET'])) { $gateway->setKey($_ENV['DWOLLA_SANDBOX_KEY']); $gateway->setSecret($_ENV['DWOLLA_SANSBOX_SECRET']); @@ -49,7 +49,7 @@ class PaymentService { return $gateway; } - public function getPaymentDetails($invitation, $input = null) + public function getPaymentDetails($invitation, $accountGateway, $input = null) { $invoice = $invitation->invoice; $account = $invoice->account; @@ -66,8 +66,7 @@ class PaymentService { } $card = new CreditCard($data); - - return [ + $data = [ 'amount' => $invoice->getRequestedAmount(), 'card' => $card, 'currency' => $currencyCode, @@ -77,6 +76,12 @@ class PaymentService { 'transactionId' => $invoice->invoice_number, 'transactionType' => 'Purchase', ]; + + if ($accountGateway->isGateway(GATEWAY_PAYPAL_EXPRESS) || $accountGateway->isGateway(GATEWAY_PAYPAL_PRO)) { + $data['ButtonSource'] = 'InvoiceNinja_SP'; + }; + + return $data; } public function convertInputForOmnipay($input)