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


PHP Payment::update方法代码示例

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


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

示例1: WC

    function receipt_page($order_id)
    {
        $order = new WC_Order($order_id);
        WC()->session->ppp_order_id = $order_id;
        $PaymentData = AngellEYE_Gateway_Paypal::calculate($order, true);
        $payment = new Payment();
        $payment->setId(WC()->session->paymentId);
        $patchReplace = new \PayPal\Api\Patch();
        $patchReplace->setOp('replace')->setPath('/transactions/0/amount')->setValue(json_decode('{
                    "total": "' . number_format($order->get_total(), 2, '.', '') . '",
                    "currency": "' . get_woocommerce_currency() . '",
                    "details": {
                        "subtotal": "' . $PaymentData['itemamt'] . '",
                        "shipping": "' . $PaymentData['shippingamt'] . '",
                        "tax":"' . $PaymentData['taxamt'] . '"
                    }
                }'));
        $patchRequest = new \PayPal\Api\PatchRequest();
        if ($order->needs_shipping_address() && !empty($order->shipping_country)) {
            //add shipping info
            $patchAdd = new \PayPal\Api\Patch();
            $patchAdd->setOp('add')->setPath('/transactions/0/item_list/shipping_address')->setValue(json_decode('{
                    "recipient_name": "' . $order->shipping_first_name . ' ' . $order->shipping_last_name . '",
                    "line1": "' . $order->shipping_address_1 . '",
                    "city": "' . $order->shipping_city . '",
                    "state": "' . $order->shipping_state . '",
                    "postal_code": "' . $order->shipping_postcode . '",
                    "country_code": "' . $order->shipping_country . '"
                }'));
            $patchRequest->setPatches(array($patchAdd, $patchReplace));
        } else {
            $patchRequest->setPatches(array($patchReplace));
        }
        try {
            $result = $payment->update($patchRequest, $this->getAuth());
            $this->add_log(print_r($payment, true));
            if ($result == true) {
            }
            ?>
        <script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js"type="text/javascript"></script>
        <script>
            jQuery(document).ready(function(){
                jQuery.blockUI({
                    message: "<?php 
            echo esc_js(__('Thank you for your order. We are now redirecting you to PayPal to make payment.', 'paypal-for-woocommerce'));
            ?>
",
                    baseZ: 99999,
                    overlayCSS:
                    {
                        background: "#fff",
                        opacity: 0.6
                    },
                    css: {
                        padding:        "20px",
                        zindex:         "9999999",
                        textAlign:      "center",
                        color:          "#555",
                        border:         "3px solid #aaa",
                        backgroundColor:"#fff",
                        cursor:         "wait",
                        lineHeight:		"24px"
                    }
                });
                PAYPAL.apps.PPP.doCheckout();
            });
        </script>
    <?php 
        } catch (PayPal\Exception\PayPalConnectionException $ex) {
            wc_add_notice(__("Error processing checkout. Please try again. ", 'woocommerce'), 'error');
            $this->add_log($ex->getData());
        } catch (Exception $ex) {
            $this->add_log($ex->getMessage());
            // Prints the Error Code
            wc_add_notice(__("Error processing checkout. Please try again.", 'woocommerce'), 'error');
        }
    }
开发者ID:spirit1977,项目名称:paypal-woocommerce,代码行数:77,代码来源:wc-gateway-paypal-plus-angelleye.php

示例2: testUpdate

 /**
  * @dataProvider mockProvider
  * @param Payment $obj
  */
 public function testUpdate($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(true));
     $patchRequest = PatchRequestTest::getObject();
     $result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:12,代码来源:PaymentTest.php


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