Skip to content

Commit

Permalink
Added ability to use a specific PayPal API.
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Apr 4, 2016
1 parent 5e4577a commit 48d4a76
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/PayPalFacadeAccessor.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
<?php namespace Srmklive\PayPal;

use Srmklive\PayPal\Services\AdaptivePayments;
use Srmklive\PayPal\Services\ExpressCheckout;

class PayPalFacadeAccessor
{
/**
* PayPal API provider object
*
* @var $provider
*/
public static $provider;

/**
* Get specific PayPal API provider object to use
*
* @return ExpressCheckout|AdaptivePayments
*/
public static function getProvider()
{
return new ExpressCheckout;
if (empty(self::$provider))
return new ExpressCheckout;
else
return self::$provider;
}

/**
* Set specific PayPal API to use
*
* @param string $option
* @return ExpressCheckout|AdaptivePayments
*/
public static function setProvider($option = '')
{
if (!in_array($option, ['express_checkout', 'adaptive_payments']))
$option = 'express_checkout';

if ($option == 'express_checkout')
self::$provider = new ExpressCheckout;
elseif ($option == 'adaptive_payments')
self::$provider = new AdaptivePayments;

return self::getProvider();
}
}

0 comments on commit 48d4a76

Please sign in to comment.