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


PHP Paypal::buildNVPString方法代码示例

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


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

示例1: paypal_set_ec

 /**
  * Starts the transaction and gets the token. Afterwards it's passed off to the final transaction method.
  * @param 
  */
 public function paypal_set_ec()
 {
     if ($this->request->is('post')) {
         //Abort if cancel button was pressed
         if (isset($this->request->data['cancel'])) {
             //Pass the user along to an action that will clear the account and the upload
             $this->redirect(array('controller' => 'users', 'action' => 'clear_user_data', $this->request->data['Upload']['user_id']));
             break;
         }
         //Check to make sure that the total codes haven't already been added to this file
         $upload = $this->Upload->read(null, $this->request->data['Upload']['id']);
         if (intval($upload['Upload']['total_codes']) > 0) {
             if (intval($upload['Upload']['total_codes']) == count($upload['Code'])) {
                 $this->Session->setFlash(__('Error! No more codes can be added to this upload. Please re-upload the file.', true), 'message_fail');
                 $this->render('paypal_back_to_add');
                 return;
             }
         }
         //do paypal setECCheckout
         App::import('Model', 'Paypal');
         $paypal = new Paypal();
         $codePrice = $this->Upload->Code->getPrice($this->request->data['Upload']['total_codes']);
         $itemName = $this->Upload->Code->getItemName($this->request->data['Upload']['total_codes']);
         $nvpStr = $paypal->buildNVPString($codePrice, $itemName, $this->request->data['Upload']['user_id'], $this->request->data['Upload']['id'], $this->request->data['Upload']['total_codes']);
         if ($paypal->setExpressCheckout($nvpStr)) {
             $result = $paypal->getPaypalUrl($paypal->token);
         } else {
             $this->log($paypal->errors);
             $result = false;
         }
         //debug($this->request);
         if (false !== $result) {
             //The result should look like the following
             //https://www.sandbox.paypal.com/incontext?token=EC-09N44269CG053064W
             $this->redirect($result);
         } else {
             $this->Session->setFlash(__('Error while connecting to PayPal, Please try again', true));
         }
     }
     $payment_options = $this->Upload->Code->getPaymentOptions();
     //Get the options array for the select list
     $this->set(compact('payment_options'));
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:47,代码来源:UploadsController.php


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