简体   繁体   English

Braintree 的 Sandbox PayPal 集成(使用 JS 和 PHP)

[英]Braintree's Sandbox PayPal Integration (using JS and PHP)

I currently working on integrating braintree to my company's website, but only for PayPal orders.我目前致力于将 Braintree 集成到我公司的网站,但仅适用于 PayPal 订单。 I am currently using braintree's sandbox.我目前正在使用 Braintree 的沙箱。 When I try to setup braintree, I use shippingAddressOverride to set the test shipping address.当我尝试设置 Braintree 时,我使用 shippingAddressOverride 来设置测试送货地址。 However, I've been getting the default shipping address returned back to me.但是,我一直在收到退回给我的默认送货地址。

<?php
require_once '_environment.php';
$clientToken = Braintree_ClientToken::generate();
?>

<html>
<head>
</head>
<body>
    <div id="paypal-container"></div> 
    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-2.1.1.js"></script>
    <script src="https://js.braintreegateway.com/v2/braintree.js"></script>
    <script>
        braintree.setup("<?php print $clientToken; ?>", "custom", {
            paypal: {
                container: "paypal-container",
                singleUse: true, // Required
                amount: 10.00, // Required
                currency: 'USD', // Required
                locale: 'en_us',
                enableShippingAddress: 'true',
                shippingAddressOverride: {
                    recipientName: 'Scruff McGruff',
                    streetAddress: '1234 Main St.',
                    extendedAddress: 'Unit 1',
                    locality: 'Chicago',
                    countryCodeAlpha2: 'US',
                    postalCode: '60652',
                    region: 'IL',
                    phone: '123.456.7890',
                    editable: false
                }
            },
            onPaymentMethodReceived: function (obj) {
                //doSomethingWithTheNonce(obj.nonce);
                console.log(obj.details.shippingAddress);
            }
        });
    </script>

</body>
</html> 

Is there a reason why I keep getting the default shipping address instead of the one that is set?有什么理由让我一直得到默认的送货地址而不是设置的地址吗?

Full disclosure: I work at Braintree.完全披露:我在布伦特里工作。

This is a known issue and Braintree devs are investigating it.这是一个已知问题,Braintree 开发人员正在调查它。 For now, if you need the shippingAddressOverride functionality I would suggest rolling back to an earlier release.现在,如果您需要 shippingAddressOverride 功能,我建议您回滚到较早的版本。 You can follow progress on resolving this at the GitHub issue that has been opened .您可以在已打开GitHub 问题中了解解决此问题的进展。 If you have any further questions, please contact Braintree support .如果您有任何其他问题,请联系Braintree 支持

I have the same issue and I tried to use an older version of braintree.js, and in version 2.7.1 it working!我有同样的问题,我尝试使用旧版本的 Braintree.js,在 2.7.1 版本中它可以工作! Maybe in newest releases of Braintree something broke:(也许在最新版本的 Braintree 中有些东西坏了:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM