当前位置: 首页>>代码示例>>PHP>>正文


PHP Paypal::enable_test_mode方法代码示例

本文整理汇总了PHP中Paypal::enable_test_mode方法的典型用法代码示例。如果您正苦于以下问题:PHP Paypal::enable_test_mode方法的具体用法?PHP Paypal::enable_test_mode怎么用?PHP Paypal::enable_test_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Paypal的用法示例。


在下文中一共展示了Paypal::enable_test_mode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: paypal

 /**
  * Ipn::paypal()
  *
  * Validate PayPal payments
  *
  * @access	public
  * @return	void
  */
 public function paypal()
 {
     // Include the paypal library
     include_once APPPATH . 'libraries/payment/Paypal.php';
     $this->_gateway = 1;
     // Create an instance of the paypal library
     $my_paypal = new Paypal();
     // Log the IPN results
     // $my_paypal->ipn_log = TRUE;
     // Enable test mode if needed
     if (defined('XUDEBUG') and XUDEBUG == true) {
         $my_paypal->enable_test_mode();
     }
     // Check validity and write down it
     if ($my_paypal->validate_ipn()) {
         if ($my_paypal->ipn_data['payment_status'] == 'Completed') {
             $settings = json_decode(base64_decode($my_paypal->ipn_data['custom']));
             if ($settings['type'] == 'reg') {
                 $this->_new_user_payment($settings['user_id'], $my_paypal->ipn_data['amount']);
                 redirect('/user/pay_complete');
             }
             redirect('/user/pay_cancel');
         } else {
             $this->_log_error($my_paypal->ipn_data);
             redirect('/user/pay_cancel');
         }
     }
     redirect('/user/pay_cancel');
 }
开发者ID:rexcarnation,项目名称:XtraUpload-1,代码行数:37,代码来源:Ipn.php

示例2: pay_new

 /**
  * User::pay_new()
  *
  * New payment
  *
  * @access	public
  * @param	int		$id			User ID
  * @param	int		$gate_id	Gateway ID
  * @return	void
  */
 public function pay_new($id = '', $gate_id = '')
 {
     if (intval($id) == 0 or intval($gate_id) == 0) {
         show_404();
     }
     $user = $this->db->get_where('users', array('id' => $id))->row();
     if (!$user or $user->status != 0) {
         show_404();
     }
     $group = $this->db->get_where('groups', array('id' => $user->group))->row();
     if (!$group) {
         show_404();
     }
     $gate = $this->db->get_where('gateways', array('id' => $gate_id))->row();
     if (!$gate) {
         show_404();
     }
     // get payment gateway settings
     $gate_conf = unserialize($gate->settings);
     // load payment libs
     include_once APPPATH . 'libraries/payment/PaymentGateway.php';
     // which payment system to use?
     if ($gate->name == 'paypal') {
         // Include the paypal library
         include_once APPPATH . 'libraries/payment/Paypal.php';
         // Create an instance of the paypal library
         $my_paypal = new Paypal();
         // Specify your paypal email
         $my_paypal->add_field('business', $gate_conf['email']);
         // Specify the currency
         $my_paypal->add_field('currency_code', $gate_conf['currency']);
         // Specify the url where paypal will send the user on success/failure
         $my_paypal->add_field('return', site_url('user/pay_complete'));
         $my_paypal->add_field('cancel_return', site_url('user/pay_cancel'));
         // Specify the url where paypal will send the IPN
         $my_paypal->add_field('notify_url', site_url('payment/ipn/paypal'));
         // Specify the product information
         $my_paypal->add_field('item_name', $this->startup->site_config->sitename . ' ' . lang('Account Registration'));
         $my_paypal->add_field('amount', $group->price);
         $my_paypal->add_field('item_number', rand(1, 1000) . '-' . $user->id);
         // Specify any custom value
         $my_paypal->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
         // Enable test mode if needed
         if (defined('XUDEBUG') and XUDEBUG == true) {
             $my_paypal->enable_test_mode();
         }
         // Let's start the train!
         $data['form'] = $my_paypal->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.'));
     } else {
         if ($gate->name == 'authorize') {
             // Include the paypal library
             include_once APPPATH . 'libraries/payment/Authorize.php';
             // Create an instance of the authorize.net library
             $my_authorize = new Authorize();
             // Specify your authorize.net login and secret
             $my_authorize->set_user_info($gate_conf['login'], $gate_conf['secret']);
             // Specify the url where authorize.net will send the user on success/failure
             $my_authorize->add_field('x_Receipt_Link_URL', site_url('user/pay_complete'));
             // Specify the url where authorize.net will send the IPN
             $my_authorize->add_field('x_Relay_URL', site_url('payment/ipn/authorize'));
             // Specify the product information
             $my_authorize->add_field('x_Description', $this->startup->site_config->sitename . ' ' . lang('Account Registration'));
             $my_authorize->add_field('x_Amount', $group->price);
             $my_authorize->add_field('x_Invoice_num', rand(1, 1000) . '-' . $user->id);
             $my_authorize->add_field('x_Cust_ID', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
             // Enable test mode if needed
             if (defined('XUDEBUG') and XUDEBUG == true) {
                 $my_authorize->enable_test_mode();
             }
             // Let's start the train!
             $data['form'] = $my_authorize->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.'));
         } else {
             if ($gate->name = '2co') {
                 // Include the paypal library
                 include_once APPPATH . 'libraries/payment/TwoCo.php';
                 // Create an instance of the authorize.net library
                 $my2_co = new TwoCo();
                 // Specify your 2CheckOut vendor id
                 $my2_co->add_field('sid', $gate_conf['vendor_id']);
                 // Specify the order information
                 $my2_co->add_field('cart_order_id', rand(1, 1000) . '-' . $user->id);
                 $my2_co->add_field('total', $group->price);
                 // Specify the url where authorize.net will send the IPN
                 $my2_co->add_field('x_Receipt_Link_URL', site_url('payment/ipn/two_checkout'));
                 $my2_co->add_field('tco_currency', $gate_conf['currency']);
                 $my2_co->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
                 // Enable test mode if needed
                 if (defined('XUDEBUG') and XUDEBUG == true) {
                     $my2_co->enable_test_mode();
                 }
//.........这里部分代码省略.........
开发者ID:rexcarnation,项目名称:XtraUpload-1,代码行数:101,代码来源:User.php


注:本文中的Paypal::enable_test_mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。