使用PayPal API并使用来自Name-value对接口PHP源代码 SDK和下载:简化与下载和SDK的集成.

我的问题类似于删除(或预填充)PayPal Express结帐的地址详细信息“但是我不希望运输成本/地址或有关运输的任何内容。

我将所有运输详细信息保留在我的系统上(甚至有时甚至不适用,也没有收费),我只希望用户在没有运输地址和运输费用的情况下通过PayPal付款。

如何禁用结帐的一部分?

有帮助吗?

解决方案

如果您使用的是较新的API,也可以通过noshipping = 1(不是no_shipping)

有关setexpresscheckout的所有可能参数的更多详细信息:

https://developer.paypal.com/webapps/develveper/docs/classic/api/merchant/seteppresscheckout_api_operation_operation_nvp/

或查找 付款经验 在新的REST API中

其他提示

嘿,埃尔吉克,只需沿着 no_shipping 值的参数 1.

来自贝宝的 文档:

no_shipping

Do not prompt payers for shipping address. Allowable values:
0 – prompt for an address, but do not require one
1 – do not prompt for an address
2 – prompt for an address, and require one
The default is 0.

当前正确的答案是 堕落. 。要解决新API的问题,我们应该创建 付款网络体验资料资源 使用所需的参数并将其附加到请求 支付 .

PHP中的示例:

/** Note: Define some variables yourself. */

$inputFields = new InputFields();
$inputFields->setAllowNote(true)
    ->setNoShipping(1) // Important step
    ->setAddressOverride(0);

$webProfile = new WebProfile();
$webProfile->setName(uniqid())
    ->setInputFields($inputFields)
    ->setTemporary(true);

$createProfile = $webProfile->create($apiContext);

$payment = new Payment();

$payment->setPayer($payer);
$payment->setIntent($intent);
$payment->setRedirectUrls($redirectUrls)
$payment->setTransactions(array($transaction));
$payment->setExperienceProfileId($createProfile->getId()); // Important step.

$payment->create($apiContext);

if ($payment->getState() === "created") {
    $approvalLink = $payment->getApprovalLink()

    header("Location: $approvalLink"); // Redirects user to PayPal page.
}

笔记: 您可以通过链接找到上述所有二手类: https://github.com/paypal/paypal-php-sdk/tree/master/lib/paypal/api

根据API中的示例创建Web配置文件: CreateWebProfile.php.

$createProfileResponse = require  __DIR__ . '/CreateWebProfile.php';
$payment = new Payment(); 
$payment->setExperienceProfileId($createProfileResponse->getId());

文件路径: paypal/rest-api-sdk-php/sample/payment-experience/CreateWebProfile.php

@ergec:我尝试了:

$nvpstr = "&ADDRESSOVERRIDE=1".$shiptoAddress."&L_NAME0=".$L_NAME0."&L_NAME1=".$L_NAME1."&L_AMT0=".$L_AMT0."&L_AMT1=".$L_AMT1."&L_QTY0=".$L_QTY0."&L_QTY1=".$L_QTY1."&MAXAMT=".(string)$maxamt."&ITEMAMT=".(string)$itemamt."&AMT=".$itemamt."&ReturnUrl=".$returnURL."&CANCELURL=".$cancelURL."&CURRENCYCODE=".$currencyCodeType;

有用。在这里,即使我们没有收取任何费用,我们也可以使用运输地址。

为了从当前(2019)Web Client .js解决此问题,请添加 application_context 阻止请求主体。

以下是一个例子 createSubscription() 称呼;我认为这将与 createOrder() 也是

paypal.Buttons({
          createSubscription: function (data, actions) {

              return actions.subscription.create({

                  'plan_id'            : 'P-123',
                  'application_context': {
                      'shipping_preference': 'NO_SHIPPING'
                  }
              });
          },

          onApprove: function (data, actions) {

              // ...
          }
      })
      .render('#paypal-button-container');

多亏了这里的示例代码:

这是列出字段枚举的地方:

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top