Paypal 贝宝结账-don';t询问非会员的送货地址?
我刚刚开始玩这个模块: 我正在想办法关闭客户的送货地址。我知道在订购版本中,您可以在URL中执行Paypal 贝宝结账-don';t询问非会员的送货地址?,paypal,Paypal,我刚刚开始玩这个模块: 我正在想办法关闭客户的送货地址。我知道在订购版本中,您可以在URL中执行&NOSHIPPING=1,但我找不到关于API 4版本的任何信息。我的代码是: paypal.Button.render({ // Pass the client ids to use to create your transaction on sandbox and production environments locale: 'fr_FR', //env: 'pr
&NOSHIPPING=1
,但我找不到关于API 4版本的任何信息。我的代码是:
paypal.Button.render({
// Pass the client ids to use to create your transaction on sandbox and production environments
locale: 'fr_FR',
//env: 'production',
env: 'sandbox',
client: {
sandbox: "...",
production: "..."
},
// Pass the payment details for your transaction
// See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters
payment: function() {
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {
total: window.my_config.grand_total,
currency: 'EUR',
details: {
"subtotal": window.my_config.price,
"tax": window.my_config.vat_amount
}
},
}
]
});
},
// Display a "Pay Now" button rather than a "Continue" button
commit: true,
// Pass a function to be called when the customer completes the payment
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
console.log('The payment was completed!');
console.log(data, actions)
if (error === 'INSTRUMENT_DECLINED') {
actions.restart();
}
});
},
// Pass a function to be called when the customer cancels the payment
onCancel: function(data) {
console.log('The payment was cancelled!');
},
style: {
shape: 'rect',
size: "medium"
}
}, '#paypalContainerEl');
对于新API,您需要设置参数
no_shipping=1
您需要通过
支付
功能中体验
下的禁止发货
选项,如下所示:
return actions.payment.create(
{
payment:
{
transactions: [
{
amount:
{
total: "10",
currency: 'EUR'
}
}]
},
experience:
{
input_fields:
{
no_shipping: 1
}
}
});
在文档中,以及。不过有一点需要注意的是,客人仍然会被询问他们的账单地址,即使他们的送货地址不再被询问。对于通过PayPal REST API使用C#集成此功能的倒霉小伙子来说,这有点棘手 您可以创建一个
WebProfile
,如中所示
var experienceProfile=new WebProfile()
{
name=Guid.NewGuid().ToString(),//必填字段
输入字段=新输入字段()
{
无装运=1
}
};
var experienceId=experienceProfile.Create(_apiContext).id;
新付款
{
intent=“销售”,
付款人=新付款人
{
付款方式=“贝宝”
},
事务=新列表
{
// ...
},
重定向\u URL=新的重定向URL
{
return_url=“…”,
取消url=“…”
},
经验\个人资料\ id=经验id
};
对于通过PHP中的PayPal REST API集成的用户,要设置no_shipping属性:
apiContext = $this->apiContext;
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');
$inputFields = new \PayPal\Api\InputFields();
$inputFields->setNoShipping(1); //<-- NO SHIPPING!!!!!!!!!!
$webProfile = new \PayPal\Api\WebProfile();
$webProfile->setName($uid); // <-- UNIQUE NAME FOR THE TRANSACTION
$webProfile->setInputFields($inputFields);
$createProfileResponse = $webProfile->create($apiContext);
$webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext);
$amount = new \PayPal\Api\Amount();
$amount->setCurrency('EUR')
->setTotal($this->deposit_eur);
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl($this->return_url)
->setCancelUrl($this->cancel_url);
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction))
->setExperienceProfileId($webProfile->getId()); //<-- SET EXPERIENCE PROFILE
try{
$payment->create($apiContext);
} catch (\Exception $ex) {
debug($ex);
exit;
}
$approvalUrl = $payment->getApprovalLink();
apiContext=$this->apiContext;
$payer=new\PayPal\Api\payer();
$payer->setPaymentMethod('paypal');
$inputFields=new\PayPal\Api\inputFields();
$inputFields->setNoShipping(1)//setName($uid);//setInputFields($inputFields);
$createProfileResponse=$webProfile->create($apiContext);
$webProfile=\PayPal\Api\webProfile::get($createProfileResponse->getId(),$apiContext);
$amount=new\PayPal\Api\amount();
$amount->setCurrency('EUR')
->setTotal($此->存款欧元);
$transaction=new\PayPal\Api\transaction();
$transaction->setAmount($amount);
$redirectUrls=new\PayPal\Api\redirectUrls();
$redirectURL->setReturnUrl($this->return\uURL)
->setCancelUrl($this->cancel\uURL);
$payment=new\PayPal\Api\payment();
$payment->setIntent('销售')
->付款人(付款人)
->setRedirectUrls($redirectUrls)
->setTransactions(数组($transaction))
->setExperienceProfileId($webProfile->getId())//创建($apiContext);
}捕获(\Exception$ex){
调试($ex);
出口
}
$approvalUrl=$payment->getApprovalLink();
使用“配送”首选项:“无配送”
createOrder:函数(数据、操作){
$('#paypolmsg').html(''+'等待授权返回…'+'');
$('chkoutmsg').hide()
return actions.order.create({
购买单位:[{
描述:“GnG订单”,
金额:{
价值:总计
}
}],
应用程序上下文:{
配送首选项:“无配送”
}
});
},
谢谢-但如何使用PayPal checkout JS实现这一点?它只是作为交易:[]
部分中的一个选项吗?@AndrewNewby你知道这是怎么回事吗?@Michał已经有一段时间了——但我似乎记得当时没有选择将其放入PayPal JS API中(现在可能有所不同)@AndrewNewby有意愿,就有办法;D@Michał哈哈是的。我想我放弃了它(我们现在用Stripe支付大部分费用,但仍然为那些想使用它的人提供PayPal)的工作就像一个魅力。您链接到的checkout.js
有更好的文档吗?示例中有很多变量和函数没有很好地定义,嗯,已经有一段时间了,但我发现Paypals文档,尤其是第二个链接,并不太破旧。确保点击蓝色对象链接查看列出的所有变量。嘿,你知道如何在API的v2中做到这一点吗?文件:
apiContext = $this->apiContext;
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');
$inputFields = new \PayPal\Api\InputFields();
$inputFields->setNoShipping(1); //<-- NO SHIPPING!!!!!!!!!!
$webProfile = new \PayPal\Api\WebProfile();
$webProfile->setName($uid); // <-- UNIQUE NAME FOR THE TRANSACTION
$webProfile->setInputFields($inputFields);
$createProfileResponse = $webProfile->create($apiContext);
$webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext);
$amount = new \PayPal\Api\Amount();
$amount->setCurrency('EUR')
->setTotal($this->deposit_eur);
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl($this->return_url)
->setCancelUrl($this->cancel_url);
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction))
->setExperienceProfileId($webProfile->getId()); //<-- SET EXPERIENCE PROFILE
try{
$payment->create($apiContext);
} catch (\Exception $ex) {
debug($ex);
exit;
}
$approvalUrl = $payment->getApprovalLink();
createOrder: function(data, actions) {
$('#paypalmsg').html('<b>' + 'WAITING ON AUTHORIZATION TO RETURN...' + '</b>');
$('#chkoutmsg').hide()
return actions.order.create({
purchase_units: [{
description: 'GnG Order',
amount: {
value: cartTotal
}
}],
application_context: {
shipping_preference: 'NO_SHIPPING'
}
});
},