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


PHP Paypal::setExpressCheckout方法代码示例

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


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

示例1: merchantPayment

 public function merchantPayment()
 {
     $token = isset($this->data['token']) ? $this->data['token'] : '';
     if (isset($this->data['payment_opt'])) {
         if (!($merchant = Yii::app()->functions->getMerchantByToken($token))) {
             $this->msg = Yii::t("default", "ERROR: cannot get merchant information");
             return;
         }
         if ($this->data['payment_opt'] == "ccr") {
             if (is_numeric($this->data['cc_id'])) {
                 if (isset($this->data['renew'])) {
                     $membership_info = Yii::app()->functions->upgradeMembership($merchant['merchant_id'], $this->data['package_id']);
                     $params = array('package_id' => $this->data['package_id'], 'merchant_id' => $merchant['merchant_id'], 'price' => $membership_info['package_price'], 'payment_type' => $this->data['payment_opt'], 'mt_id' => $this->data['cc_id'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'membership_expired' => $membership_info['membership_expired']);
                     $this->insertData("{{package_trans}}", $params);
                     $params_update = array('package_id' => $this->data['package_id'], 'package_price' => $membership_info['package_price'], 'membership_expired' => $membership_info['membership_expired'], 'membership_purchase_date' => date('c'), 'status' => 'active');
                     $this->updateData("{{merchant}}", $params_update, 'merchant_id', $merchant['merchant_id']);
                     $this->code = 1;
                     $this->msg = Yii::t("default", "Payment Successful");
                 } else {
                     $params = array('package_id' => $merchant['package_id'], 'merchant_id' => $merchant['merchant_id'], 'price' => $merchant['package_price'], 'payment_type' => $this->data['payment_opt'], 'mt_id' => $this->data['cc_id'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']);
                     if ($package = Yii::app()->functions->getPackagesById($merchant['package_id'])) {
                         $expiration = $package['expiration'];
                         $membership_expired = date('Y-m-d', strtotime("+{$expiration} days"));
                         $params['membership_expired'] = $membership_expired;
                     }
                     if ($this->insertData("{{package_trans}}", $params)) {
                         $this->code = 1;
                         $this->msg = Yii::t("default", "Payment Successful");
                         $this->details = $token;
                         $this->updateData("{{merchant}}", array('payment_steps' => 3, 'membership_purchase_date' => date('c')), 'merchant_id', $merchant['merchant_id']);
                     } else {
                         $this->msg = Yii::t("default", "ERROR: Cannot insert records.");
                     }
                 }
             } else {
                 $this->msg = Yii::t("default", "Please select credit card.");
             }
         } elseif ($this->data['payment_opt'] == "pyp") {
             if (isset($this->data['renew'])) {
                 if ($new_info = Yii::app()->functions->getPackagesById($this->data['package_id'])) {
                     $package_price = $new_info['price'];
                     if ($new_info['promo_price'] > 0) {
                         $package_price = $new_info['promo_price'];
                     }
                     $merchant['package_name'] = $new_info['title'];
                     $merchant['package_id'] = $new_info['package_id'];
                 } else {
                     $package_price = 0;
                 }
             } else {
                 $package_price = $merchant['package_price'];
             }
             $paypal_con = Yii::app()->functions->getPaypalConnectionAdmin();
             $params = '';
             $x = 0;
             $params['L_NAME' . $x] = isset($merchant['package_name']) ? $merchant['package_name'] : Yii::t("default", "No description");
             $params['L_NUMBER' . $x] = $merchant['package_id'];
             $params['L_DESC' . $x] = isset($merchant['package_name']) ? $merchant['package_name'] : Yii::t("default", "No description");
             $params['L_AMT' . $x] = normalPrettyPrice($package_price);
             $params['L_QTY' . $x] = 1;
             $params['AMT'] = normalPrettyPrice($package_price);
             /** add card fee */
             $card_fee = Yii::app()->functions->getOptionAdmin('admin_paypal_fee');
             if (!empty($card_fee) && $card_fee >= 0.1) {
                 $x++;
                 $params['L_NAME' . $x] = t("Card Fee");
                 $params['L_DESC' . $x] = t("Card Fee");
                 $params['L_AMT' . $x] = normalPrettyPrice($card_fee);
                 $params['L_QTY' . $x] = 1;
                 $params['AMT'] = $params['AMT'] + $card_fee;
             }
             if (isset($this->data['renew'])) {
                 $params['RETURNURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3a/internal-token/{$token}/renew/1/package_id/" . $this->data['package_id'];
             } else {
                 $params['RETURNURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3a/internal-token/{$token}";
             }
             $params['CANCELURL'] = "http://" . $_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3/token/{$token}";
             $params['NOSHIPPING'] = '1';
             $params['LANDINGPAGE'] = 'Billing';
             $params['SOLUTIONTYPE'] = 'Sole';
             $params['CURRENCYCODE'] = adminCurrencyCode();
             $paypal = new Paypal($paypal_con);
             $paypal->params = $params;
             $paypal->debug = false;
             if ($resp = $paypal->setExpressCheckout()) {
                 $this->code = 1;
                 $this->msg = Yii::t("default", "Please wait while we redirect you to paypal.");
                 $this->details = $resp['url'];
             } else {
                 $this->msg = $paypal->getError();
             }
         } elseif ($this->data['payment_opt'] == "stp") {
             /*STRIPE*/
             $this->code = 1;
             $this->msg = Yii::t("default", "Please wait while we redirect you to stripe");
             $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}";
             if (isset($this->data['renew'])) {
                 $this->details = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3b/token/{$token}/renew/1/package_id/" . $this->data['package_id'];
             }
         } elseif ($this->data['payment_opt'] == "mcd") {
//.........这里部分代码省略.........
开发者ID:ashishvazirani,项目名称:food,代码行数:101,代码来源:AjaxAdmin.php

示例2: t

             $card_fee = Yii::app()->functions->getOption('merchant_paypal_fee', $merchant_id);
         }
         if (!empty($card_fee) && $card_fee >= 0.1) {
             $x++;
             $params['L_NAME' . $x] = t("Card Fee");
             $params['L_DESC' . $x] = t("Card Fee");
             $params['L_AMT' . $x] = normalPrettyPrice($card_fee);
             $params['L_QTY' . $x] = 1;
             $params['AMT'] = $params['AMT'] + $card_fee;
         }
         /*dump($params);
           die();*/
         $paypal = new Paypal($paypal_con);
         $paypal->params = $params;
         $paypal->debug = false;
         if ($resp = $paypal->setExpressCheckout()) {
             $insert['token'] = $resp['token'];
             $insert['order_id'] = isIsset($_GET['id']);
             $insert['date_created'] = date('c');
             $insert['ip_address'] = $_SERVER['REMOTE_PORT'];
             $insert['paypal_request'] = json_encode($paypal->params);
             $insert['paypal_response'] = json_encode($resp['resp']);
             Yii::app()->functions->paypalSavedToken($insert);
             header('Location: ' . $resp['url']);
         } else {
             $error = $paypal->getError();
         }
     }
 } else {
     $error = Yii::t("default", "Merchant Paypal Credential not yet been set.");
 }
开发者ID:ashishvazirani,项目名称:food,代码行数:31,代码来源:paypal-init.php

示例3: array

 function paypal_set_ec($order_no = '')
 {
     //pr($this->data);
     if (!empty($this->data)) {
         $user_id = $this->Session->read('Auth.User.id');
         if ($this->data['payment_option'] == 'paypal') {
             $order_details = $this->OrderDetail->find('all', array('conditions' => array('order_no' => $order_no, 'is_paid' => '0')));
             if (empty($order_details)) {
                 $this->redirect('/');
             } else {
                 $total = 0;
                 foreach ($order_details as $order_detail) {
                     $total = $total + $order_detail['OrderDetail']['total_amount'];
                 }
                 //pr($order_details);exit;
             }
             /*$save_order = array();
               $save_order['Payment']['user_id'] = $user_id;
               $save_order['Payment']['order_no'] = $order_no;
               $save_order['Payment']['amount'] = $total;
               $save_order['Payment']['method'] = '0';
               $save_order['Payment']['shipping_amount'] = '0';
               $save_order['Payment']['token'] = '0';
               pr($this->data);exit;*/
             $min_order_price = $this->Orderprices->find('first');
             $ShippingPrice = $this->ShippingPrice->find('first');
             if ($min_order_price['Orderprices']['price'] >= $total) {
                 $total1 = $total + $ShippingPrice['ShippingPrice']['price'];
                 $shipping = 'ship';
                 $shipping_amount = $ShippingPrice['ShippingPrice']['price'];
             } else {
                 $total1 = $total;
                 $shipping_amount = 0;
             }
             //build nvp string
             //use your own logic to get and set each variable
             $returnURL = Router::url(array('controller' => 'purchases', 'action' => 'paypal_return'), true);
             $cancelURL = Router::url(array('controller' => 'purchases', 'action' => 'paypal_cancel'), true);
             $nvpStr = "RETURNURL={$returnURL}&CANCELURL={$cancelURL}";
             $nvpStr .= "&PAYMENTREQUEST_0_CURRENCYCODE=MYR";
             $nvpStr .= "&PAYMENTREQUEST_0_AMT=" . number_format($total1, 2, '.', '');
             $nvpStr .= "&PAYMENTREQUEST_0_ITEMAMT=" . number_format($total, 2, '.', '');
             $nvpStr .= "&AYMENTREQUEST_0_PAYMENTACTION=sale";
             $nvpStr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital";
             $nvpStr .= "&L_PAYMENTREQUEST_0_NAME0=Harimau LTD \n Order#" . $order_no;
             $nvpStr .= "&L_PAYMENTREQUEST_0_QTY0=1";
             $nvpStr .= "&L_PAYMENTREQUEST_0_AMT0=" . number_format($total, 2, '.', '');
             if (isset($shipping) and $shipping == 'ship') {
                 $nvpStr .= "&PAYMENTREQUEST_0_SHIPPINGAMT=" . number_format($ShippingPrice['ShippingPrice']['price'], 2, '.', '');
             }
             /*$nvpStr=
                "RETURNURL=$returnURL&CANCELURL=$cancelURL"
               ."&PAYMENTREQUEST_0_CURRENCYCODE=MYR"           
               ."&PAYMENTREQUEST_0_AMT=15"
               ."&PAYMENTREQUEST_0_ITEMAMT=10"
               ."&AYMENTREQUEST_0_PAYMENTACTION=Sale"
               ."&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital"
               ."&L_PAYMENTREQUEST_0_NAME0=test"
               ."&L_PAYMENTREQUEST_0_QTY0=1"
               ."&L_PAYMENTREQUEST_0_AMT0=10"          
               ."&PAYMENTREQUEST_0_SHIPPINGAMT=5.00"
               ;     */
             //do paypal setECCheckout
             App::import('Model', 'Paypal');
             $paypal = new Paypal();
             if ($paypal->setExpressCheckout($nvpStr)) {
                 $save_order = array();
                 $payment_order = $this->Payment->findByOrderNo($order_no);
                 if (empty($payment_order)) {
                     $save_order['Payment']['user_id'] = $user_id;
                     $save_order['Payment']['order_no'] = $order_no;
                     $save_order['Payment']['amount'] = number_format($total, 2, '.', '');
                     $save_order['Payment']['method'] = '0';
                     $save_order['Payment']['shipping_amount'] = $shipping_amount;
                     $save_order['Payment']['token'] = $paypal->token;
                     $this->Payment->save($save_order);
                 }
                 $result = $paypal->getPaypalUrl($paypal->token);
             } else {
                 $this->log($paypal->errors);
                 $result = false;
             }
             pr($paypal->errors);
             if (false !== $result) {
                 $this->redirect($result);
             } else {
                 $this->Session->setFlash(__('Error while connecting to PayPal, Please try again', true));
             }
             exit;
         } else {
             if ($this->data['payment_option'] == 'molpay') {
                 $order_details = $this->OrderDetail->find('all', array('conditions' => array('order_no' => $order_no, 'is_paid' => '0')));
                 $merchant = 2;
                 $auth_key = 'QZRSggdz';
                 $total = 0;
                 foreach ($order_details as $order_detail) {
                     $total = $total + $order_detail['OrderDetail']['total_amount'];
                 }
                 $name = $order_details['0']['OrderDetail']['name'];
                 $email = $order_details['0']['User']['username'];
//.........这里部分代码省略.........
开发者ID:beyondkeysystem,项目名称:testone,代码行数:101,代码来源:PurchasesController.php

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