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


PHP Paypal::getPaypalUrl方法代码示例

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


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

示例1: Paypal

$paypal = new Paypal();
$cart = new Cart(intval($cookie->id_cart));
$address = new Address(intval($cart->id_address_invoice));
$country = new Country(intval($address->id_country));
$state = NULL;
if ($address->id_state) {
    $state = new State(intval($address->id_state));
}
$customer = new Customer(intval($cart->id_customer));
$business = Configuration::get('PAYPAL_BUSINESS');
$header = Configuration::get('PAYPAL_HEADER');
$currency_order = new Currency(intval($cart->id_currency));
$currency_module = $paypal->getCurrency();
if (!Validate::isEmail($business)) {
    die($paypal->getL('Paypal error: (invalid or undefined business account email)'));
}
if (!Validate::isLoadedObject($address) or !Validate::isLoadedObject($customer) or !Validate::isLoadedObject($currency_module)) {
    die($paypal->getL('Paypal error: (invalid address or customer)'));
}
// check currency of payment
if ($currency_order->id != $currency_module->id) {
    $cookie->id_currency = $currency_module->id;
    $cart->id_currency = $currency_module->id;
    $cart->update();
}
$smarty->assign(array('redirect_text' => $paypal->getL('Please wait, redirecting to Paypal... Thanks.'), 'cancel_text' => $paypal->getL('Cancel'), 'cart_text' => $paypal->getL('My cart'), 'return_text' => $paypal->getL('Return to shop'), 'paypal_url' => $paypal->getPaypalUrl(), 'address' => $address, 'country' => $country, 'state' => $state, 'amount' => floatval($cart->getOrderTotal(true, 4)), 'customer' => $customer, 'total' => floatval($cart->getOrderTotal(true, 3)), 'shipping' => Tools::ps_round(floatval($cart->getOrderShippingCost()) + floatval($cart->getOrderTotal(true, 6)), 2), 'discount' => $cart->getOrderTotal(true, 2), 'business' => $business, 'currency_module' => $currency_module, 'cart_id' => intval($cart->id), 'products' => $cart->getProducts(), 'paypal_id' => intval($paypal->id), 'header' => $header, 'url' => Tools::getHttpHost(true, true) . __PS_BASE_URI__));
if (is_file(_PS_THEME_DIR_ . 'modules/paypal/redirect.tpl')) {
    $smarty->display(_PS_THEME_DIR_ . 'modules/' . $paypal->name . '/redirect.tpl');
} else {
    $smarty->display(_PS_MODULE_DIR_ . $paypal->name . '/redirect.tpl');
}
开发者ID:vincent,项目名称:theinvertebrates,代码行数:31,代码来源:redirect.php

示例2: 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

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