我需要为我的应用整合paypal付款。按照我的应用程序中的所有步骤后,我需要通过支付宝网站结账,然后成功交易后我想再次返回我的应用程序?
请指导我这样做。 我可以使用braintree接受贝宝标准文字吗? 如果是,请指导我如何将其与angularjs集成?
答案 0 :(得分:0)
PayPal Standard是一个简单的表单,可将您发送到PayPal页面进行付款。你可以这样做:
shoppingCart.prototype.checkoutPayPal = function (parms, clearCart) {
// global data
var data = {
cmd: "_cart",
business: parms.merchantID,
upload: "1",
rm: "2",
charset: "utf-8"
};
// item data
for (var i = 0; i < this.items.length; i++) {
var item = this.items[i];
var ctr = i + 1;
data["item_number_" + ctr] = item.sku;
data["item_name_" + ctr] = item.name;
data["quantity_" + ctr] = item.quantity;
data["amount_" + ctr] = item.price.toFixed(2);
}
// build form
var form = $('<form></form>');
form.attr("action", "https://www.paypal.com/cgi-bin/webscr");
form.attr("method", "POST");
form.attr("style", "display:none;");
this.addFormFields(form, data);
this.addFormFields(form, parms.options);
$("body").append(form);
// submit form
this.clearCart = clearCart == null || clearCart;
form.submit();
form.remove();
}
在代码项目中有一个带有PayPal的角度购物车的非常好的示例:http://www.codeproject.com/Articles/576246/A-Shopping-Cart-Application-Built-with-AngularJS