/** * Create PayPal purchase * * @param int $post_id */ function aviators_submission_create_paypal_purchase($post_id) { aviators_submission_paypal_payment_gateway(); PayPal_Digital_Goods_Configuration::return_url(get_template_directory_uri() . '/aviators/plugins/submission/return.php?paypal=paid&post_id=' . $post_id); PayPal_Digital_Goods_Configuration::cancel_url(get_template_directory_uri() . '/aviators/plugins/submission/return.php?paypal=cancel&post_id=' . $post_id); PayPal_Digital_Goods_Configuration::notify_url(get_template_directory_uri() . '/aviators/plugins/submission/return.php?paypal=notify&post_id=' . $post_id); $post = get_post($post_id); $price = aviators_settings_get_value('submission', 'pay_per_post', 'price'); $tax = aviators_settings_get_value('submission', 'pay_per_post', 'tax'); $description = aviators_settings_get_value('submission', 'pay_per_post', 'description'); $currency = aviators_settings_get_value('submission', 'pay_per_post', 'currency_code'); $purchase_details = array('name' => get_bloginfo('name'), 'description' => get_bloginfo('description'), 'amount' => $price + $tax, 'tax_amount' => $tax, 'currency' => $currency, 'items' => array(array('item_name' => $post->post_title, 'item_description' => $description, 'item_amount' => $price, 'item_tax' => $tax, 'item_quantity' => 1, 'item_number' => $post_id))); return new PayPal_Purchase($purchase_details); }
/** * Get the symbol associated with a currency, optionally specified with '$currency_code' parameter. * * Will always return the symbol and can optionally also print the symbol. * * @param $currency_code, string, optional, the ISO 4217 Code of the currency for which you want the Symbol, default the currency code of this object * @param $echo bool, Optionally print the symbol before returning it. **/ public function get_currency_symbol($currency_code = '', $echo = false) { if (empty($currency_code)) { $currency_code = PayPal_Digital_Goods_Configuration::currency(); } switch ($currency_code) { case 'AUD': case 'CAD': case 'NZD': case 'SGD': case 'HKD': case 'TWD': case 'USD': $currency_symbol = '$'; break; case 'DKK': case 'NOK': case 'SEK': $currency_symbol = 'kr'; break; case 'EUR': $currency_symbol = '€'; break; case 'GBP': $currency_symbol = '£'; break; case 'JPY': $currency_symbol = '¥'; break; case 'CZK': $currency_symbol = 'Kč'; break; case 'HUF': $currency_symbol = 'Ft'; break; case 'PLN': $currency_symbol = 'zł'; break; case 'CHF': $currency_symbol = 'CHF'; break; } if ($echo) { echo $currency_symbol; } return $currency_symbol; }
/** * Reset the configuration to default settings * * @access public * @static */ public static function reset() { self::$_cache = array('environment' => 'sandbox', 'business_name' => '', 'cancel_url' => '', 'return_url' => '', 'notify_url' => '', 'currency' => 'USD', 'username' => '', 'password' => '', 'signature' => '', 'incontext_url' => 'yes', 'mobile_url' => 'no', 'display_address' => 'no', 'locale_code' => 'US'); }
/** * Reset the configuration to default settings * * @access public * @static */ public static function reset() { self::$_cache = array('environment' => 'sandbox', 'business_name' => '', 'cancel_url' => '', 'return_url' => '', 'notify_url' => '', 'currency' => 'USD', 'username' => '', 'password' => '', 'signature' => ''); }
/** * A central function for settings the credentials for both subscription & purchase * objects with the PayPal_Digital_Goods_Configuration registry class. */ function set_credentials() { /* PayPal_Digital_Goods_Configuration::username( 'your_api_username' ); PayPal_Digital_Goods_Configuration::password( 'your_api_password' ); PayPal_Digital_Goods_Configuration::signature( 'your_api_signature' ); */ PayPal_Digital_Goods_Configuration::username('digita_1308916325_biz_api1.gmail.com'); PayPal_Digital_Goods_Configuration::password('1308916362'); PayPal_Digital_Goods_Configuration::signature('AFnwAcqRkyW0yPYgkjqTkIGqPbSfAyVFbnFAjXCRltVZFzlJyi2.HbxW'); PayPal_Digital_Goods_Configuration::return_url(get_script_uri('return.php?paypal=paid')); PayPal_Digital_Goods_Configuration::cancel_url(get_script_uri('return.php?paypal=cancel')); PayPal_Digital_Goods_Configuration::business_name('Demo Store'); PayPal_Digital_Goods_Configuration::notify_url(get_script_uri('return.php?paypal=notify')); // Uncomment the line below to switch to the live PayPal site //PayPal_Digital_Goods_Configuration::environment( 'live' ); if (PayPal_Digital_Goods_Configuration::username() == 'your_api_username' || PayPal_Digital_Goods_Configuration::password() == 'your_api_password' || PayPal_Digital_Goods_Configuration::signature() == 'your_api_signature') { exit('You must set your API credentials in ' . __FILE__ . ' for this example to work.'); } }