Added PayPal buttonsource

This commit is contained in:
Hillel Coren 2015-10-21 07:30:23 +03:00
parent 392c1facc0
commit 7150a148af
2 changed files with 12 additions and 7 deletions

View File

@ -419,7 +419,7 @@ class PaymentController extends BaseController
} }
$gateway = $this->paymentService->createGateway($accountGateway); $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 // check if we're creating/using a billing token
if ($accountGateway->gateway_id == GATEWAY_STRIPE) { if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
@ -437,7 +437,7 @@ 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) {
@ -515,7 +515,7 @@ class PaymentController extends BaseController
try { try {
if (method_exists($gateway, 'completePurchase') && !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)) { 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(); $response = $gateway->completePurchase($details)->send();
$ref = $response->getTransactionReference(); $ref = $response->getTransactionReference();

View File

@ -36,7 +36,7 @@ class PaymentService {
$gateway->$function($val); $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'])) { if ($gateway->getSandbox() && isset($_ENV['DWOLLA_SANDBOX_KEY']) && isset($_ENV['DWOLLA_SANSBOX_SECRET'])) {
$gateway->setKey($_ENV['DWOLLA_SANDBOX_KEY']); $gateway->setKey($_ENV['DWOLLA_SANDBOX_KEY']);
$gateway->setSecret($_ENV['DWOLLA_SANSBOX_SECRET']); $gateway->setSecret($_ENV['DWOLLA_SANSBOX_SECRET']);
@ -49,7 +49,7 @@ class PaymentService {
return $gateway; return $gateway;
} }
public function getPaymentDetails($invitation, $input = null) public function getPaymentDetails($invitation, $accountGateway, $input = null)
{ {
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$account = $invoice->account; $account = $invoice->account;
@ -66,8 +66,7 @@ class PaymentService {
} }
$card = new CreditCard($data); $card = new CreditCard($data);
$data = [
return [
'amount' => $invoice->getRequestedAmount(), 'amount' => $invoice->getRequestedAmount(),
'card' => $card, 'card' => $card,
'currency' => $currencyCode, 'currency' => $currencyCode,
@ -77,6 +76,12 @@ class PaymentService {
'transactionId' => $invoice->invoice_number, 'transactionId' => $invoice->invoice_number,
'transactionType' => 'Purchase', 'transactionType' => 'Purchase',
]; ];
if ($accountGateway->isGateway(GATEWAY_PAYPAL_EXPRESS) || $accountGateway->isGateway(GATEWAY_PAYPAL_PRO)) {
$data['ButtonSource'] = 'InvoiceNinja_SP';
};
return $data;
} }
public function convertInputForOmnipay($input) public function convertInputForOmnipay($input)