/**
  * Creates a PayPal Digital Goods Subscription Object configured according to the parameters in the $subscription_details associative array. 
  * 
  * Available $subscription_details parameters:
  * - subscription_details, array, details of the recurring payment profile to be created.
  * 		- description, string, Brief description of the subscription as shown to the subscriber in their PayPal account.
  * 		Subscription price parameters (default: $25 per month):
  * 		- amount, double, default 25.00. The price per period for the subscription.
  * 		- initial_amount, double, default 0. An optional sign up fee.
  * 		- average_amount, double, default 25.00. The average transaction amount, PayPal default is $25, only set higher if your monthly subscription value is higher
  * 		Subscription temporal parameters (default: bill once per month forever):
  * 		- start_date, date, default 24 hours in the future. The start date for the profile, defaults to one day in the future. Must take the form YYYY-MM-DDTHH:MM:SS and can not be in the past.
  * 		- period, Day|Week|Month|Semimonth, default Month. The unit of interval between billing.
  * 		- frequency, integer, default 1. How regularly to charge the amount. When period is Month, a frequency value of 1 would charge every month while a frequency value of 12 charges once every year.
  * 		- total_cycles, integer, default perpetuity. The total number of occasions the subscriber should be charged. When period is month and frequency is 1, 12 would continue the subscription for one year. The default value 0 will continue the payment for perpetuity.
  * 		Subscription trial period parameters (default: no trial period):
  * 		- trial_amount, double, default 0. The price per trial period.
  * 		- trial_period, Day|Week|Month|Semimonth, default Month. The unit of interval between trial period billing.
  * 		- trial_frequency, integer, default 0. How regularly to charge the amount.
  * 		- trial_total_cycles, integer, default perpetuity. 
  * 
  * @param $subscription_details, named parameters to customise the subscription prices, periods and frequencies.
  */
 public function __construct($subscription_details = array())
 {
     $subscription_defaults = array('description' => 'Digital Goods Subscription', 'invoice_number' => '', 'max_failed_payments' => '', 'amount' => '25.00', 'initial_amount' => '0.00', 'average_amount' => '25', 'tax_amount' => '0.00', 'start_date' => date('Y-m-d\\TH:i:s', time() + 24 * 60 * 60), 'period' => 'Month', 'frequency' => '1', 'total_cycles' => '0', 'trial_amount' => '0.00', 'trial_period' => 'Month', 'trial_frequency' => '0', 'trial_total_cycles' => '0', 'add_to_next_bill' => true);
     $subscription_details = array_merge($subscription_defaults, $subscription_details);
     $this->subscription = (object) $subscription_details;
     parent::__construct();
 }
 /**
  * Creates a PayPal Digital Goods Object configured according to the parameters in the args associative array. 
  * 
  * Available $args parameters:
  * - purchase_details, array, details of the purchase.
  * 		- description, string, (Optional) Description of items the buyer is purchasing.
  * 		Transaction Totals:
  * 		- amount, double, required. Total cost of the transaction to the buyer, including tax.
  * 		- tax, double, default 0.00. The sum of tax for all items in this order. 
  * 		- invoice_number, string, (Optional) Your own invoice or tracking number. Can be up to 127 single-byte alphanumeric characters.
  * 		Item details:
  * 		- items array, An array of arrays for each item in this transaction.
  * 			- item_name, string, Item name. 
  * 			- item_description, string, (Optional) Item description.
  * 			- item_amount, string, (Optional) Cost of this individual item.
  * 			- item_quantity, string, default 1. Number of this specific item.
  * 			- item_tax, string, (Optional) Sales tax of this individual item.
  * 			- item_number, string, (Optional) Your own invoice or tracking number. Can be up to 127 single-byte alphanumeric characters.
  *		Miscellaneous
  * 		- custom (Optional) A free-form field for your own use. 
  * 
  * @todo Allow purchase details to include more than one item. 
  * 
  * @param args, named parameters to customise the subscription and checkout process. See description for available parameters.
  */
 public function __construct($purchase_details = array())
 {
     $purchase_defaults = array('name' => 'Digital Good', 'description' => '', 'amount' => '5.00', 'tax_amount' => '0.00', 'invoice_number' => '', 'number' => '', 'items' => array(), 'custom' => '');
     $purchase_details = array_merge($purchase_defaults, $purchase_details);
     // Make it super simple to create a single item transaction
     if (empty($purchase_details['items'])) {
         $purchase_details['items'] = array(array('item_name' => $purchase_details['name'], 'item_description' => $purchase_details['description'], 'item_amount' => $purchase_details['amount'], 'item_tax' => $purchase_details['tax_amount'], 'item_quantity' => 1, 'item_number' => $purchase_details['number']));
     }
     $this->purchase = (object) $purchase_details;
     parent::__construct();
 }