How to process PayPal payments in an ionic app for Woocommerce? How to process PayPal payments in an ionic app for Woocommerce? wordpress wordpress

How to process PayPal payments in an ionic app for Woocommerce?


You are almost there. If you dont want to purchase plugin, you can do it manually. For example, set the notify_url parameter to your site, with i.e.pp_respond (or whatever you want).

enter image description here

In your functions.php, put this code:

if(isset($_GET['pp_respond'])){    file_put_contents(__DIR__."/my_notificationssss.txt", $_SERVER['REQUEST_URI']. "\r\n". print_r($_POST,true) . "\r\n ------------- \r\n" , FILE_APPEND);}

then make a test purchase, and along the functions.php file there will be a new file named my-notificationssss.txt, and look through that file, and find out your desired parameters to use in the future.


One possible solution would be to add the order information to the users session before sending the user to Paypal.

After the user pays via Paypal, redirect them to a "success" url (Specified in the PayPal request). When the user goes to this success url, you can then update the order in WooCommerce using the session information.


After looking in woo commerce source code it seems like it adds it's own order ID to PayPal's invoiceNumber section.

So if you have woo commerce PayPal plugin on your site (it should IPN enabled), You can use PayPal Cordova plugin in ionic 2 by passing woo commerce order ID to invoiceNumber. Like the example below:

EDIT: Although woo commerce does add invoice number, I now believe the most important params that are passed is the custom param.

pay() {    let payment = new PayPalPayment(this.data.price, this.data.currency, this.data.description, 'sale');    payment.custom = JSON.stringify({ order_id: this.data.WOOCOMMERCE_ORDERID, order_key: this.data.WOOCOMMERCE_ORDERKEY });    this.payPal.renderSinglePaymentUI(payment).then((response) => {        console.log(response);        // Successfully paid        // Example sandbox response        //        // {        //   "client": {        //     "environment": "sandbox",        //     "product_name": "PayPal ANDROID SDK",        //     "paypal_sdk_version": "2.16.0",        //     "platform": "iOS"        //   },        //   "response_type": "payment",        //   "response": {        //     "id": "PAY-1AB23456CD789012EF34GHIJ",        //     "state": "approved",        //     "create_time": "2016-10-03T13:33:33Z",        //     "intent": "sale"        //   }        // }    }, () => {        // Error or render dialog closed without being successful    });}