Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Ionic Issue #1

Closed
honey93 opened this issue Sep 17, 2017 · 1 comment
Closed

Ionic Issue #1

honey93 opened this issue Sep 17, 2017 · 1 comment

Comments

@honey93
Copy link

honey93 commented Sep 17, 2017

I installed your plugin cordova plugin add cordova-plugin-inappbrowser-popup-bridge

Then I initialized in main.js file :

document.addEventListener("deviceReady",function(){


  window.open = cordova.InAppBrowser.open;

});

In html used it like:

<div id="myContainerElement"></div>

In controller file I used it:

paypal.Button.render({

    env: 'sandbox', // Optional: specify 'sandbox' environment

    client: {
        sandbox:    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        production: 'xxxxxxxxx'
    },

    payment: function() {
    
        var env    = this.props.env;
        var client = this.props.client;
    
        return paypal.rest.payment.create(env, client, {
            transactions: [
                {
                    amount: { total: vm , currency: 'USD' }
                }
            ]
        });
    },

    commit: true, // Optional: show a 'Pay Now' button in the checkout flow

    onAuthorize: function(data, actions) {
    
        // Optional: display a confirmation page here
        $scope.payment = false;
    
        return actions.payment.execute().then(function() {
            // Show a success page to the buyer
            $scope.payment = false;
        });
    },

    onCancel: function(data) {
        console.log('The payment was cancelled!');
        //$scope.payment = false;
        $scope.$apply();
    }

}, '#myContainerElement');

Still the paypal button is not getting displayed on click of button, could you please help me out:

@dpa99c
Copy link
Owner

dpa99c commented Sep 17, 2017

I believe you won't be able to host the page containing the Paypal Checkout code within the app - it will fail the CORS checks on the PayPal servers (if you inspect the JS console in the IAB Webview, you'll see a bunch of security errors).
The page must be hosted on a server, and that URL opened from within the InappBrowser.

I've created a branch of the demo project: https://github.com/dpa99c/cordova-plugin-inappbrowser-popup-bridge-test/tree/paypal-checkout

It uses a test page hosted on my server: http://demos.workingedge.co.uk/iab.html

Try cloning and running the test project:

git clone https://github.com/dpa99c/cordova-plugin-inappbrowser-popup-bridge-test#paypal-checkout
cordova platform add android
cordova run android

@dpa99c dpa99c closed this as completed Sep 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants