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


PHP PayPal::APICallSuccessful方法代码示例

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


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

示例1: array


//.........这里部分代码省略.........
                         $item['name'] .= " - " . str_replace(", \n", " - ", $meta);
                     }
                 }
                 /**
                  * Get price based on text setting.
                  */
                 if (get_option('woocommerce_prices_include_tax') == 'yes') {
                     $product_price = $order->get_item_subtotal($item, true, false);
                 } else {
                     $product_price = $order->get_item_subtotal($item, false, true);
                 }
                 $Item = array('l_name' => $item['name'], 'l_desc' => '', 'l_amt' => number_format($product_price, 2, '.', ''), 'l_number' => $sku, 'l_qty' => $item['qty'], 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
                 array_push($OrderItems, $Item);
                 $ITEMAMT += $product_price * $item['qty'];
                 $item_loop++;
             }
         }
         //Cart Discount
         if ($order->get_cart_discount() > 0) {
             foreach (WC()->cart->get_coupons('cart') as $code => $coupon) {
                 $Item = array('l_name' => 'Cart Discount', 'l_desc' => '', 'l_amt' => '-' . WC()->cart->coupon_discount_amounts[$code], 'l_number' => $code, 'l_qty' => '1', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
                 array_push($OrderItems, $Item);
             }
             $ITEMAMT = $ITEMAMT - $order->get_cart_discount();
         }
         //Order Discount
         if ($order->get_order_discount() > 0) {
             foreach (WC()->cart->get_coupons('order') as $code => $coupon) {
                 $Item = array('l_name' => 'Order Discount', 'l_desc' => '', 'l_amt' => '-' . WC()->cart->coupon_discount_amounts[$code], 'l_number' => $code, 'l_qty' => '1', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
                 array_push($OrderItems, $Item);
             }
             $ITEMAMT = $ITEMAMT - $order->get_order_discount();
         }
         /**
          * Get shipping and tax.
          */
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $shipping = $order->get_total_shipping() + $order->get_shipping_tax();
             $tax = 0;
         } else {
             $shipping = $order->get_total_shipping();
             $tax = $order->get_total_tax();
         }
         if ($tax > 0) {
             $PaymentDetails['taxamt'] = $tax;
             // Required if you specify itemized cart tax details. Sum of tax for all items on the order.  Total sales tax.
         }
         if ($shipping > 0) {
             $PaymentDetails['shippingamt'] = $shipping;
             // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
         }
         $PaymentDetails['itemamt'] = number_format($ITEMAMT, 2, '.', '');
         // Required if you include itemized cart details. (L_AMTn, etc.)  Subtotal of items not including S&H, or tax.
     }
     if ($this->debug) {
         $log = $post_data;
         $log['ACCT'] = '****';
         $log['CVV2'] = '****';
         $this->log->add('paypal-pro', 'Do payment request ' . print_r($log, true));
     }
     /**
      * 3D Secure Params
      */
     if ($this->enable_3dsecure) {
         $Secure3D = array('authstatus3d' => $centinelPAResStatus, 'mpivendor3ds' => $centinelEnrolled, 'cavv' => $centinelCavv, 'eci3ds' => $centinelEciFlag, 'xid' => $centinelXid);
     } else {
         $Secure3D = array();
     }
     $PayPalRequestData = array('DPFields' => $DPFields, 'CCDetails' => $CCDetails, 'PayerInfo' => $PayerInfo, 'BillingAddress' => $BillingAddress, 'ShippingAddress' => $ShippingAddress, 'PaymentDetails' => $PaymentDetails, 'OrderItems' => $OrderItems, 'Secure3D' => $Secure3D);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->DoDirectPayment($PayPalRequestData);
     if ($this->debug) {
         $this->log->add('paypal-pro', 'Result ' . print_r($PayPalResult, true));
     }
     if (empty($PayPalResult)) {
         throw new Exception(__('Empty PayPal response.', 'wc_paypal_pro'));
     }
     if ($PayPal->APICallSuccessful($PayPalResult['ACK'])) {
         // Add order note
         $order->add_order_note(sprintf(__('PayPal Pro payment completed (Transaction ID: %s, Correlation ID: %s)', 'wc_paypal_pro'), $parsed_response['TRANSACTIONID'], $parsed_response['CORRELATIONID']));
         // Payment complete
         $order->payment_complete();
         // Remove cart
         WC()->cart->empty_cart();
         // Return thank you page redirect
         return array('result' => 'success', 'redirect' => $this->get_return_url($order));
     } else {
         if ($this->debug) {
             $this->log->add('paypal-pro', 'Error ' . print_r($PayPalResult['ERRORS'], true));
         }
         throw new Exception(__('There was a problem connecting to the payment gateway.', 'wc_paypal_pro'));
         // Get error message
         $error_code = $PayPalResult['ERRORS'][0]['L_ERRORCODE'];
         $error_message = $error_code . '-' . $PayPalResult['ERRORS'][0]['L_LONGMESSAGE'];
         // Payment failed :(
         $order->update_status('failed', sprintf(__('PayPal Pro payment failed (Correlation ID: %s). Payment was rejected due to an error: ', 'wc_paypal_pro'), $parsed_response['CORRELATIONID']) . '(' . $parsed_response['L_ERRORCODE0'] . ') ' . '"' . $error_message . '"');
         wc_add_notice(__('Payment error:', 'wc_paypal_pro') . ' ' . $error_message, "error");
         return;
     }
 }
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:101,代码来源:wc-gateway-paypal-pro-angelleye.php

示例2: ConfirmPayment


//.........这里部分代码省略.........
     $ITEMAMT = 0;
     if (sizeof($order->get_items()) > 0) {
         foreach ($order->get_items() as $values) {
             $_product = $order->get_product_from_item($values);
             $qty = absint($values['qty']);
             $sku = $_product->get_sku();
             $values['name'] = html_entity_decode($values['name'], ENT_NOQUOTES, 'UTF-8');
             if ($_product->product_type == 'variation') {
                 if (empty($sku)) {
                     $sku = $_product->parent->get_sku();
                 }
                 $item_meta = new WC_Order_Item_Meta($values['item_meta']);
                 $meta = $item_meta->display(true, true);
                 if (!empty($meta)) {
                     $values['name'] .= " - " . str_replace(", \n", " - ", $meta);
                 }
             }
             /*
              * Set price based on tax option.
              */
             if (get_option('woocommerce_prices_include_tax') == 'yes') {
                 $product_price = $order->get_item_subtotal($values, true, false);
             } else {
                 $product_price = $order->get_item_subtotal($values, false, true);
             }
             $Item = array('name' => $values['name'], 'desc' => '', 'amt' => $product_price, 'number' => $sku, 'qty' => $qty, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
             array_push($PaymentOrderItems, $Item);
             $ITEMAMT += $product_price * $values['qty'];
         }
         /*
          * Get discounts
          */
         if ($order->get_cart_discount() > 0) {
             foreach (WC()->cart->get_coupons('cart') as $code => $coupon) {
                 $Item = array('name' => 'Cart Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_cart_discount();
         }
         if ($order->get_order_discount() > 0) {
             foreach (WC()->cart->get_coupons('order') as $code => $coupon) {
                 $Item = array('name' => 'Order Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
                 array_push($PaymentOrderItems, $Item);
             }
             $ITEMAMT -= $order->get_order_discount();
         }
         /*
          * Set shipping and tax values.
          */
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             $shipping = $order->get_total_shipping() + $order->get_shipping_tax();
             $tax = 0;
         } else {
             $shipping = $order->get_total_shipping();
             $tax = $order->get_total_tax();
         }
         /*
          * Now that we have all items and subtotals
          * we can fill in necessary values.
          */
         $Payment['itemamt'] = number_format($ITEMAMT, 2, '.', '');
         // Required if you specify itemized L_AMT fields. Sum of cost of all items in this order.
         /*
          * Set tax
          */
         if ($tax > 0) {
             $Payment['taxamt'] = number_format($tax, 2, '.', '');
             // Required if you specify itemized L_TAXAMT fields.  Sum of all tax items in this order.
         }
         /*
          * Set shipping
          */
         if ($shipping > 0) {
             $Payment['shippingamt'] = number_format($shipping, 2, '.', '');
             // Total shipping costs for this order.  If you specify SHIPPINGAMT you mut also specify a value for ITEMAMT.
         }
     }
     $Payment['order_items'] = $PaymentOrderItems;
     array_push($Payments, $Payment);
     $UserSelectedOptions = array('shippingcalculationmode' => '', 'insuranceoptionselected' => '', 'shippingoptionisdefault' => '', 'shippingoptionamount' => '', 'shippingoptionname' => '');
     $PayPalRequestData = array('DECPFields' => $DECPFields, 'Payments' => $Payments);
     // Pass data into class for processing with PayPal and load the response array into $PayPalResult
     $PayPalResult = $PayPal->DoExpressCheckoutPayment($PayPalRequestData);
     /*
      * Log API result
      */
     $this->add_log('Test Mode: ' . $this->testmode);
     $this->add_log('Endpoint: ' . $this->API_Endpoint);
     $this->add_log('Result: ' . print_r($PayPalResult, true));
     /*
      * Error handling
      */
     if ($PayPal->APICallSuccessful($PayPalResult['ACK'])) {
         $this->remove_session('TOKEN');
     }
     /*
      * Return the class library result array.
      */
     return $PayPalResult;
 }
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php


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