/** * Creates a PayPal Digital Goods Object configured according to the parameters in the args associative array. * * Available $args parameters: * - cancel_url, string, required. The URL on your site that the purchaser is sent to when cancelling a payment during the checkout process. * - return_url, string, required. The URL on your site that the purchaser is sent to upon completing checkout. * - notify_url, string, optional. The URL for receiving Instant Payment Notification (IPN) about this transaction. * - solution_type, string, optional. Type of checkout flow. It is one of Sole (default, buyer does not need to create a PayPal account to check out) or Mark (buyer must have a PayPal account to check out) * - sandbox, boolean. Flag to indicate whether to use the PayPal Sandbox or live PayPal site. Default true - use sandbox. * - business_name, string. A label that overrides the business name in the PayPal account on the PayPal hosted checkout pages. * * @param api_credentials, required, a name => value array containing your API username, password and signature. * @param args, named parameters to customise the subscription and checkout process. See description for available parameters. */ public function __construct($args = array()) { if ('' == PayPal_Digital_Goods_Configuration::username() || '' == PayPal_Digital_Goods_Configuration::password() || '' == PayPal_Digital_Goods_Configuration::signature()) { throw new Exception('You must specify your PayPal API username, password & signature in the $api_credentials array.'); } elseif (empty($args['return_url']) && '' == PayPal_Digital_Goods_Configuration::username() || empty($args['cancel_url']) && '' == PayPal_Digital_Goods_Configuration::cancel_url()) { throw new Exception('You must specify a return_url & cancel_url.'); } $defaults = array('sandbox' => true, 'business_name' => '', 'solution_type' => 'Sole', 'return_url' => PayPal_Digital_Goods_Configuration::return_url(), 'cancel_url' => PayPal_Digital_Goods_Configuration::cancel_url(), 'notify_url' => PayPal_Digital_Goods_Configuration::notify_url(), 'display_address' => PayPal_Digital_Goods_Configuration::display_address(), 'locale_code' => PayPal_Digital_Goods_Configuration::locale_code()); $args = array_merge($defaults, $args); $this->currency = PayPal_Digital_Goods_Configuration::currency(); $this->business_name = $args['business_name']; $this->return_url = $args['return_url']; $this->cancel_url = $args['cancel_url']; $this->notify_url = $args['notify_url']; $this->solution_type = $args['solution_type']; $this->display_address = $args['display_address']; $this->locale_code = $args['locale_code']; }