简体   繁体   中英

How can i integrate paypal standard in my app using angularjs?

I need to integrate paypal payment for my app. After following all steps in my app I need to checkout by going to paypal site and then after successful transaction I want to return to my app again?

Please guide my to do so. Can I use braintree for accepting paypal standard wensites? If yes, please guide me how to integrate it with angularjs?

PayPal Standard is a simple form which send you to the PayPal page for payment. You can do something like this:

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();
}

There is a very good example of an angular shopping cart with PayPal on codeproject: http://www.codeproject.com/Articles/576246/A-Shopping-Cart-Application-Built-with-AngularJS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM