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

Fix Braintree when using the iFrame feature

This commit is contained in:
Hillel Coren 2017-03-29 21:45:41 +03:00
parent cd8d1c7db7
commit 7f25147e97
3 changed files with 25 additions and 11 deletions

View File

@ -935,17 +935,6 @@ class BasePaymentDriver
$account = $this->account();
$url = URL::to("/payment/{$this->invitation->invitation_key}/{$gatewayTypeAlias}");
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
// PayPal doesn't allow being run in an iframe so we need to open in new tab
if ($gatewayTypeId === GATEWAY_TYPE_PAYPAL) {
$url .= '#braintree_paypal';
if ($account->iframe_url) {
return 'javascript:window.open("' . $url . '", "_blank")';
}
}
return $url;
}

View File

@ -5,6 +5,7 @@ namespace App\Ninja\PaymentDrivers;
use Braintree\Customer;
use Exception;
use Session;
use App\Models\GatewayType;
class BraintreePaymentDriver extends BasePaymentDriver
{
@ -62,6 +63,17 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $customer instanceof Customer;
}
protected function paymentUrl($gatewayTypeAlias)
{
$url = parent::paymentUrl($gatewayTypeAlias);
if (GatewayType::getIdFromAlias($gatewayTypeAlias) === GATEWAY_TYPE_PAYPAL) {
$url .= '#braintree_paypal';
}
return $url;
}
protected function paymentDetails($paymentMethod = false)
{
$data = parent::paymentDetails($paymentMethod);

View File

@ -28,4 +28,17 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
return $payment;
}
protected function paymentUrl($gatewayTypeAlias)
{
$url = parent::paymentUrl($gatewayTypeAlias);
// PayPal doesn't allow being run in an iframe so we need to open in new tab
if ($this->account()->iframe_url) {
return 'javascript:window.open("' . $url . '", "_blank")';
} else {
return $url;
}
}
}