代码之家  ›  专栏  ›  技术社区  ›  Ergec

禁用贝宝快捷结帐中的送货地址选项

  •  22
  • Ergec  · 技术社区  · 15 年前

    使用PayPal API并使用名称-值对接口PHP源代码 SDKs and Downloads: Simplify Integrations with Downloads and SDKs .

    我的问题类似于 Removing (or prefilling) the address details for PayPal Express Checkout “但我根本不想要运费/地址或任何与运费有关的东西。

    我在我的系统上保留所有的运输细节(即使有时运输甚至不适用,也不收费),我只希望用户通过贝宝支付,没有运输地址和运输成本。

    如何禁用结帐的发货部分?

    5 回复  |  直到 8 年前
        1
  •  30
  •   Eugen Konkov    8 年前

    如果使用较新的API,还可以传递no shipping=1(而不是no-shipping)

    有关SetExpressCheckout的所有可能参数的更多详细信息,请参见:

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

    或查找 Payment experience 在新的REST API中

        2
  •  14
  •   James Skidmore    15 年前

    嘿,呃,就这样 no_shipping 值为的参数 1 .

    从贝宝 documentation :

    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.
        3
  •  5
  •   starlocke    7 年前

    目前正确的答案是 去种族化 . 为了在新的API中解决这个问题,我们应该创建 支付web体验配置文件资源 带有所需参数并将其附加到请求 付款 .

    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

        4
  •  2
  •   elkrari    10 年前

    根据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

        5
  •  2
  •   Gene Bo Krzysztof Dziuba    6 年前

    要从current(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');
    

    感谢这里的示例代码:

    下面列出了字段枚举:

        6
  •  1
  •   Raphaël Vigée    10 年前

    @我试过了:

    $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;
    

    它起作用了。在这里我们也可以使用送货地址,即使我们不收取任何费用。

    推荐文章