我想在 PayPal 付款后自动返回将客户重定向回我的网站?
我想将客户还给特定页面(例如: https://www.example.com/谢谢)一旦付款付款,并且不从PayPal沙盒设置进行付款,我想从我在网站上使用的以下脚本中添加重定向:
PayPal:function(a){if(!a.email)return b.error("No email provided for PayPal checkout");
var d={cmd:"_cart",upload:"1",
currency_code:b.currency().code,
business:a.email,
rm:"GET"===a.method?"0":"2",
tax_cart:(1*b.tax()).toFixed(2),
handling_cart:(1*b.shipping()).toFixed(2),
charset:"utf-8"},
c=a.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",
g="GET"===a.method?"GET":"POST";
a.success&&(d["return"]=a.success);
a.cancel&&(d.cancel_return=a.cancel);
a.notify&&(d.notify_url=a.notify);
b.each(function(a,c){var g=c+1,
e=a.options(),
f=0,h;d["item_name_"+g]=a.get("name");
d["quantity_"+g]=a.quantity();
d["amount_"+g]=(1*a.price()).toFixed(2);
d["item_number_"+g]=a.get("item_number")||g;
b.each(e,function(a,c,e){10>c&&(h=!0,b.each(m.excludeFromCheckout,function(a){a===e&&(h=!1)}),h&&(f+=1,d["on"+c+"_"+g]=e,d["os"+c+"_"+g]=a))});
d["option_index_"+c]=Math.min(10,f)});
return{action:c,method:g,data:d}},
GoogleCheckout:function(a){
if(!a.merchantID)return b.error("No merchant id provided for GoogleCheckout");
if("USD"!==b.currency().code&&"GBP"!==b.currency().code)
return b.error("Google Checkout only accepts USD and GBP");
var d={ship_method_name_1:"Shipping",ship_method_price_1:b.shipping(),ship_method_currency_1:b.currency().code,_charset_:""},
c="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantID;a="GET"===a.method?"GET":"POST";
b.each(function(a,c){var e=c+1,f=[],h;d["item_name_"+e]=a.get("name");d["item_quantity_"+e]=a.quantity();d["item_price_"+e]=a.price();d["item_currency_ "+e]=b.currency().code;d["item_tax_rate"+e]=a.get("taxRate")||b.taxRate();b.each(a.options(),function(a,d,c){h=!0;b.each(m.excludeFromCheckout,function(a){a===c&&(h=!1)});h&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")});
return{action:c,method:a,data:d}},
AmazonPayments:function(a){
if(!a.merchant_signature)
return b.error("No merchant signature provided for Amazon Payments");
if(!a.merchant_id)
return b.error("No merchant id provided for Amazon Payments");
if(!a.aws_access_key_id)
return b.error("No AWS access key id provided for Amazon Payments");
var d={aws_access_key_id:a.aws_access_key_id,merchant_signature:a.merchant_signature,currency_code:b.currency().code,tax_rate:b.taxRate(),weight_unit:a.weight_unit||"lb"},
c="https://payments"+(a.sandbox?"-sandbox":"")+".amazon.com/checkout/"+a.merchant_id,g="GET"===a.method?"GET":"POST";
b.each(function(c,g){
var e=g+1,f=[];
d["item_title_"+e]=c.get("name");d["item_quantity_"+e]=c.quantity();
d["item_price_"+e]=c.price();d["item_sku_ "+e]=c.get("sku")||c.id();
d["item_merchant_id_"+e]=a.merchant_id;c.get("weight")&&(d["item_weight_"+e]=c.get("weight"));
m.shippingQuantityRate&&(d["shipping_method_price_per_unit_rate_"+e]=m.shippingQuantityRate);
b.each(c.options(),function(a,d,c){var g=!0;b.each(m.excludeFromCheckout,
function(a){a===c&&(g=!1)});
g&&"weight"!==c&&"tax"!==c&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")});
return{action:c,method:g,data:d}},
SendForm:function(a){
if(!a.url)return b.error("URL required for SendForm Checkout");
var d={currency:b.currency().code,shipping:b.shipping(),tax:b.tax(),taxRate:b.taxRate(),itemCount:b.find({}).length},
c=a.url,g="GET"===a.method?"GET":"POST";
b.each(function(a,c){
var g=c+1,e=[],f;d["item_name_"+g]=a.get("name");d["item_quantity_"+g]=a.quantity();
d["item_price_"+g]=a.price();b.each(a.options(),function(a,d,c){f=!0;
b.each(m.excludeFromCheckout,function(a){a===c&&(f=!1)});
f&&e.push(c+": "+a)});
d["item_options_"+g]=e.join(", ")});
a.success&&(d["return"]=a.success);a.cancel&&(d.cancel_return=a.cancel);
a.extra_data&&(d=b.extend(d,a.extra_data));
return{action:c,method:g,data:d}
}
});
我已经进行了一些研究并找到了这一点:
<input type="hidden" name="return" value="https://www.example.com/thank-you" />
但是它是为了旧的整合,我认为它不会与我合作。通过我提供的代码,付款后显示了“返回商人”按钮,并未自动重定向到“ https://www.example.com/thank-you”。
I want to return my customers back to a specific page (example: https://www.example.com/thank-you) once the payment is made and without doing it from PayPal sandbox settings, I want to add the redirection from the below script I'm using on my website:
PayPal:function(a){if(!a.email)return b.error("No email provided for PayPal checkout");
var d={cmd:"_cart",upload:"1",
currency_code:b.currency().code,
business:a.email,
rm:"GET"===a.method?"0":"2",
tax_cart:(1*b.tax()).toFixed(2),
handling_cart:(1*b.shipping()).toFixed(2),
charset:"utf-8"},
c=a.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",
g="GET"===a.method?"GET":"POST";
a.success&&(d["return"]=a.success);
a.cancel&&(d.cancel_return=a.cancel);
a.notify&&(d.notify_url=a.notify);
b.each(function(a,c){var g=c+1,
e=a.options(),
f=0,h;d["item_name_"+g]=a.get("name");
d["quantity_"+g]=a.quantity();
d["amount_"+g]=(1*a.price()).toFixed(2);
d["item_number_"+g]=a.get("item_number")||g;
b.each(e,function(a,c,e){10>c&&(h=!0,b.each(m.excludeFromCheckout,function(a){a===e&&(h=!1)}),h&&(f+=1,d["on"+c+"_"+g]=e,d["os"+c+"_"+g]=a))});
d["option_index_"+c]=Math.min(10,f)});
return{action:c,method:g,data:d}},
GoogleCheckout:function(a){
if(!a.merchantID)return b.error("No merchant id provided for GoogleCheckout");
if("USD"!==b.currency().code&&"GBP"!==b.currency().code)
return b.error("Google Checkout only accepts USD and GBP");
var d={ship_method_name_1:"Shipping",ship_method_price_1:b.shipping(),ship_method_currency_1:b.currency().code,_charset_:""},
c="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantID;a="GET"===a.method?"GET":"POST";
b.each(function(a,c){var e=c+1,f=[],h;d["item_name_"+e]=a.get("name");d["item_quantity_"+e]=a.quantity();d["item_price_"+e]=a.price();d["item_currency_ "+e]=b.currency().code;d["item_tax_rate"+e]=a.get("taxRate")||b.taxRate();b.each(a.options(),function(a,d,c){h=!0;b.each(m.excludeFromCheckout,function(a){a===c&&(h=!1)});h&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")});
return{action:c,method:a,data:d}},
AmazonPayments:function(a){
if(!a.merchant_signature)
return b.error("No merchant signature provided for Amazon Payments");
if(!a.merchant_id)
return b.error("No merchant id provided for Amazon Payments");
if(!a.aws_access_key_id)
return b.error("No AWS access key id provided for Amazon Payments");
var d={aws_access_key_id:a.aws_access_key_id,merchant_signature:a.merchant_signature,currency_code:b.currency().code,tax_rate:b.taxRate(),weight_unit:a.weight_unit||"lb"},
c="https://payments"+(a.sandbox?"-sandbox":"")+".amazon.com/checkout/"+a.merchant_id,g="GET"===a.method?"GET":"POST";
b.each(function(c,g){
var e=g+1,f=[];
d["item_title_"+e]=c.get("name");d["item_quantity_"+e]=c.quantity();
d["item_price_"+e]=c.price();d["item_sku_ "+e]=c.get("sku")||c.id();
d["item_merchant_id_"+e]=a.merchant_id;c.get("weight")&&(d["item_weight_"+e]=c.get("weight"));
m.shippingQuantityRate&&(d["shipping_method_price_per_unit_rate_"+e]=m.shippingQuantityRate);
b.each(c.options(),function(a,d,c){var g=!0;b.each(m.excludeFromCheckout,
function(a){a===c&&(g=!1)});
g&&"weight"!==c&&"tax"!==c&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")});
return{action:c,method:g,data:d}},
SendForm:function(a){
if(!a.url)return b.error("URL required for SendForm Checkout");
var d={currency:b.currency().code,shipping:b.shipping(),tax:b.tax(),taxRate:b.taxRate(),itemCount:b.find({}).length},
c=a.url,g="GET"===a.method?"GET":"POST";
b.each(function(a,c){
var g=c+1,e=[],f;d["item_name_"+g]=a.get("name");d["item_quantity_"+g]=a.quantity();
d["item_price_"+g]=a.price();b.each(a.options(),function(a,d,c){f=!0;
b.each(m.excludeFromCheckout,function(a){a===c&&(f=!1)});
f&&e.push(c+": "+a)});
d["item_options_"+g]=e.join(", ")});
a.success&&(d["return"]=a.success);a.cancel&&(d.cancel_return=a.cancel);
a.extra_data&&(d=b.extend(d,a.extra_data));
return{action:c,method:g,data:d}
}
});
I have doing some research and found this:
<input type="hidden" name="return" value="https://www.example.com/thank-you" />
But its for the old integration and I don't think it's gonna be working with me. With the code i've provided it nly showed "Return to Merchant" button after payment, didn't automatically redirect to "https://www.example.com/thank-you".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用:
或者如果您想模拟 http 重定向:
来源:W3School 重定向到另一个页面< /a>
You could use:
or if you want to simulate an http redirect:
Source: W3School Redirect to Another Page