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(); $account = $this->account();
$url = URL::to("/payment/{$this->invitation->invitation_key}/{$gatewayTypeAlias}"); $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; return $url;
} }

View File

@ -5,6 +5,7 @@ namespace App\Ninja\PaymentDrivers;
use Braintree\Customer; use Braintree\Customer;
use Exception; use Exception;
use Session; use Session;
use App\Models\GatewayType;
class BraintreePaymentDriver extends BasePaymentDriver class BraintreePaymentDriver extends BasePaymentDriver
{ {
@ -62,6 +63,17 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $customer instanceof Customer; 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) protected function paymentDetails($paymentMethod = false)
{ {
$data = parent::paymentDetails($paymentMethod); $data = parent::paymentDetails($paymentMethod);

View File

@ -28,4 +28,17 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
return $payment; 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;
}
}
} }