在PayPal Express Checkout中禁用送货地址选项

时间:2022-10-14 15:01:16

Working with the PayPal API and using the Name-Value Pair Interface PHP source codes from SDKs and Downloads: Simplify Integrations with Downloads and SDKs.

使用PayPal API并使用SDK和下载中的名称 - 值对接口PHP源代码:简化与下载和SDK的集成。

My question is similar to "Removing (or prefilling) the address details for PayPal Express Checkout" but I don't want shipping cost/address or anything related about shipping at all.

我的问题类似于“删除(或预先填写)PayPal Express Checkout的地址详细信息”,但我不想要运输费用/地址或任何与运输相关的内容。

I keep all shipping details on my system (even sometimes shipping doesn't even apply and there is no charge for it) and I just want user to pay through PayPal without shipping address and shipping cost.

我保留了我的系统上的所有运输详细信息(即使有时甚至没有运费,也没有收费)我只是希望用户通过PayPal付款而不收取运费和运费。

How can I disable shipping part of checkout?

如何禁用部分结账?

5 个解决方案

#1


29  

If you're using the newer API, you could also pass NOSHIPPING=1 (not no_shipping)

如果您使用的是较新的API,您也可以传递NOSHIPPING = 1(不是no_shipping)

Further details about all possible parameters to the SetExpressCheckout here:

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

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

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

Or lookup for Payment experience in new REST API

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

#2


13  

Hey Ergec, just pass along the no_shipping parameter with a value of 1.

嘿Ergec,只需传递no_shipping参数,值为1。

From PayPal's documentation:

来自PayPal的文档:

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


2  

Create a web profile based on the example found in the API: CreateWebProfile.php.

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

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

File path: paypal/rest-api-sdk-php/sample/payment-experience/CreateWebProfile.php

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

#4


1  

@Ergec : I tried this:

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

It works. Here we can also use shipping address even though we are not charging any amount.

有用。在这里,我们也可以使用送货地址,即使我们不收取任何金额。

#5


1  

The current right answer is depracated. To fix the issue in new API we should create Payment web experience profile resource with needed parameters and attach it to request Payment .

目前正确的答案是贬低的。要解决新API中的问题,我们应该创建包含所需参数的付款Web体验配置文件资源,并将其附加到请求付款。

Example in PHP:

PHP中的示例:

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

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

$webProfile = new (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.
}

Note: You can find all above used classes by link: https://github.com/paypal/PayPal-PHP-SDK/tree/master/lib/PayPal/Api

注意:您可以通过链接找到以上使用的所有类:https://github.com/paypal/PayPal-PHP-SDK/tree/master/lib/PayPal/Api

#1


29  

If you're using the newer API, you could also pass NOSHIPPING=1 (not no_shipping)

如果您使用的是较新的API,您也可以传递NOSHIPPING = 1(不是no_shipping)

Further details about all possible parameters to the SetExpressCheckout here:

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

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

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

Or lookup for Payment experience in new REST API

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

#2


13  

Hey Ergec, just pass along the no_shipping parameter with a value of 1.

嘿Ergec,只需传递no_shipping参数,值为1。

From PayPal's documentation:

来自PayPal的文档:

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


2  

Create a web profile based on the example found in the API: CreateWebProfile.php.

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

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

File path: paypal/rest-api-sdk-php/sample/payment-experience/CreateWebProfile.php

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

#4


1  

@Ergec : I tried this:

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

It works. Here we can also use shipping address even though we are not charging any amount.

有用。在这里,我们也可以使用送货地址,即使我们不收取任何金额。

#5


1  

The current right answer is depracated. To fix the issue in new API we should create Payment web experience profile resource with needed parameters and attach it to request Payment .

目前正确的答案是贬低的。要解决新API中的问题,我们应该创建包含所需参数的付款Web体验配置文件资源,并将其附加到请求付款。

Example in PHP:

PHP中的示例:

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

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

$webProfile = new (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.
}

Note: You can find all above used classes by link: https://github.com/paypal/PayPal-PHP-SDK/tree/master/lib/PayPal/Api

注意:您可以通过链接找到以上使用的所有类:https://github.com/paypal/PayPal-PHP-SDK/tree/master/lib/PayPal/Api