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

I am working on an ionic 2 application, which is basically a shopping cart with Woocommerce as a backend. REST was pretty good with the REST API: I can browse products and create orders for the customer in the application.

But now I'm stuck in processing payments. The application will only use PayPal, and there is a PayPal plugin that I would like to use. I have not tested it, but it looks pretty simple: you pass the purchase details (price, currency, description ...), and then render the PayPal user interface.

I can provide all this information in the PayPal user interface, but it has an obvious question: how do I integrate it with the corresponding Woocommerce order? How to make a payment successful, Woocommerce registers it as such?

Woocommerce installation already includes PayPal. You can use PayPal on the website just fine.

Now I'm sure this has something to do with PayPal's IPN. Accepting a wild assumption, perhaps I need to somehow transfer the order identifier to the PayPal plugin so that IPN transfers the same Woocommerce order identifier? Something like that may be possible, but I cannot find the correct documentation about it.

If you search for โ€œionic 2 woocommerce paypalโ€, you'll see a lot of people selling source code pretty much for the same purpose. I could buy it and study it, but itโ€™s better to find documentation about this particular action.

+6
source share
3 answers

You are almost there. If you do not want to buy the plugin, you can do it manually. For example, set a parameter notify_urlto your site, for example pp_respond(or whatever).

enter image description here

In your functions.phpenter 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);
}

, functions.php my-notificationssss.txt, .

0

Paypal.

, Paypal, URL- "success" ( PayPal). URL- , WooCommerce, .

0

woo commerce , InvoiceNumber PayPal.

, PayPal ( IPN), PayPal Cordova 2, woo invoiceNumber. :

EDIT: although woo commerce adds an account number, now I believe that the most important parameters that are passed are parameters custom.

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
    });
}
0
source

Source: https://habr.com/ru/post/1016127/


All Articles