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


PHP Payment::setExperienceProfileId方法代码示例

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


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

示例1: getPayment

 /**
  * @see http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html
  *
  * @return Payment
  */
 public function getPayment()
 {
     $payer = $this->getPayer();
     if (!$payer || !$payer instanceof Payer) {
         throw new InvalidArgumentException("Method getPayer has to return instance of Payer. Instead " . gettype($payer) . " given.");
     }
     if (!$payer->getPaymentMethod()) {
         $payer->setPaymentMethod('paypal');
     }
     $payment = new Payment();
     $payment->setIntent("sale")->setPayer($payer);
     if ($this->context->getExperienceProfileId()) {
         $payment->setExperienceProfileId($this->context->getExperienceProfileId());
     }
     $transactions = $this->getTransactions();
     $this->checkTransactions($transactions);
     $payment->setTransactions($transactions);
     return $payment;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:24,代码来源:BasePaymentOperation.php

示例2: Payer


//.........这里部分代码省略.........
             $item[$i] = new Item();
             $item[$i]->setName($this->encode_utf8($order->products[$i]['name']))->setCurrency($order->info['currency'])->setQuantity($order->products[$i]['qty'])->setPrice($order->products[$i]['price'])->setSku($order->products[$i]['model'] != '' ? $order->products[$i]['model'] : $order->products[$i]['id']);
             $subtotal += $order->products[$i]['price'] * $order->products[$i]['qty'];
         }
         // set totals
         if ($order_exists === false) {
             if (!class_exists('order_total')) {
                 require_once DIR_WS_CLASSES . 'order_total.php';
             }
             $order_total_modules = new order_total();
             $order_totals = $order_total_modules->process();
             $this->get_totals($order_totals, true, $subtotal);
         } else {
             $this->get_totals($order->totals);
         }
         // set amount
         $this->amount->setCurrency($order->info['currency'])->setDetails($this->details);
         // set redirect
         if ($order_exists === false) {
             $redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')))->setCancelUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')));
         } else {
             $redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link('callback/paypal/' . $this->code . '.php', 'oID=' . $order->info['order_id'] . '&key=' . md5($order->customer['email_address']), 'SSL')))->setCancelUrl($this->link_encoding(xtc_href_link('callback/paypal/' . $this->code . '.php', 'payment_error=' . $this->code . '&oID=' . $order->info['order_id'] . '&key=' . md5($order->customer['email_address']), 'SSL')));
         }
         if ($this->code == 'paypalinstallment') {
             $redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'conditions=true', 'SSL')));
         }
     }
     // set ItemList
     if ($this->get_config('PAYPAL_ADD_CART_DETAILS') == '0' || $this->check_discount() === true) {
         $item = array();
         $item[0] = new Item();
         $item[0]->setName($this->encode_utf8(MODULE_PAYMENT_PAYPAL_TEXT_ORDER))->setCurrency($_SESSION['currency'])->setQuantity(1)->setPrice($this->details->getSubtotal());
         if ($cart === true) {
             $shipping_cost = $this->get_config('MODULE_PAYMENT_' . strtoupper($this->code) . '_SHIPPING_COST');
             if ((int) $shipping_cost > 0) {
                 $item[1] = new Item();
                 $item[1]->setName($this->encode_utf8(PAYPAL_EXP_VORL))->setCurrency($_SESSION['currency'])->setQuantity(1)->setPrice($shipping_cost);
                 $this->amount->setTotal($this->amount->getTotal() + $shipping_cost);
                 $this->details->setSubtotal($this->amount->getTotal());
             }
         }
     }
     $itemList->setItems($item);
     // profile
     $address_override = false;
     $profile_id = $this->get_config('PAYPAL_' . strtoupper($this->code . '_' . $_SESSION['language_code']) . '_PROFILE');
     if ($profile_id == '') {
         $profile_id = $this->get_config('PAYPAL_STANDARD_PROFILE');
     }
     if ($profile_id != '') {
         if ($this->get_config(strtoupper($profile_id) . '_TIME') < time() - 3600 * 24) {
             $profile = $this->get_profile($profile_id);
             $sql_data_array = array(array('config_key' => strtoupper($profile_id) . '_TIME', 'config_value' => time()), array('config_key' => strtoupper($profile_id) . '_ADDRESS', 'config_value' => $profile[0]['input_fields']['address_override']));
             $this->save_config($sql_data_array);
             $address_override = $profile[0]['input_fields']['address_override'] == '0' ? true : false;
         } else {
             $address_override = $this->get_config(strtoupper($profile_id) . '_ADDRESS') == '0' ? true : false;
         }
     }
     if ($cart === false && $approval === false && $address_override === false || $order_exists === true || $this->code == 'paypalinstallment') {
         $itemList->setShippingAddress($shipping_address);
     }
     if ($this->code == 'paypalinstallment') {
         // set payment address
         $payment_address = new Address();
         $payment_address->setLine1($this->encode_utf8($order->billing['street_address']))->setCity($this->encode_utf8($order->billing['city']))->setState($this->encode_utf8($order->billing['state'] != '' ? xtc_get_zone_code($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state']) : ''))->setPostalCode($this->encode_utf8($order->billing['postcode']))->setCountryCode($this->encode_utf8($order->billing['country']['iso_code_2']));
         if ($order->billing['suburb'] != '') {
             $payment_address->setLine2($this->encode_utf8($order->billing['suburb']));
         }
         $payer_info->setBillingAddress($payment_address)->setShippingAddress($shipping_address)->setEmail($this->encode_utf8($order->customer['email_address']))->setFirstName($this->encode_utf8($order->delivery['firstname']))->setLastName($this->encode_utf8($order->delivery['lastname']));
         $payer->setPayerInfo($payer_info);
     }
     // set transaction
     $transaction = new Transaction();
     $transaction->setAmount($this->amount)->setItemList($itemList)->setDescription($this->encode_utf8(STORE_NAME))->setInvoiceNumber(uniqid());
     // set payment
     $payment = new Payment();
     $payment->setIntent($this->transaction_type)->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction))->setCreateTime(time());
     if (isset($profile_id) && $profile_id != '') {
         $payment->setExperienceProfileId($profile_id);
     }
     try {
         $payment->create($apiContext);
         $_SESSION['paypal']['paymentId'] = $payment->getId();
         $approval_link = $payment->getApprovalLink();
         if ($approval === false) {
             xtc_redirect($approval_link);
         } else {
             return $approval_link;
         }
     } catch (Exception $ex) {
         $this->LoggingManager->log(print_r($ex, true), 'DEBUG');
         unset($_SESSION['paypal']);
         if ($cart === true) {
             xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'SSL'));
         } elseif ($this->code != 'paypalplus') {
             xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL'));
         }
     }
 }
开发者ID:shophelfer,项目名称:shophelfer.com-shop,代码行数:101,代码来源:PayPalPayment.php


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