poiuytrez / AndroidInAppBilling

Android App Billing plugin for Cordova
173 stars 144 forks source link

how to use InAppBilling plugin with remote phonegap build @ build.phonegap.com #96

Open equry opened 9 years ago

equry commented 9 years ago

Hi, is it possible to use this pluggin with phonegap remote build, if yes please share the steps how?

if no, please share how to add this to an existing remote phone gap project.

here is my project,

1) i have a single html file like following and config file has this setting

<gap:plugin name="com.smartmobilesoftware.inappbilling" version="3.0.2" />

2)

<!DOCTYPE html>
<html>
<body>
        <h1>Hello World</h1>
        <button onclick="init()">Initalize the billing plugin</button>
        <button onclick="buy()">Purchase</button>
        <button onclick="ownedProducts()">Owned products</button>
        <button onclick="consumePurchase()">Consume purchase</button>
        <button onclick="subscribe()">Subscribe</button>
        <button onclick="getDetails()">Query Details</button>
        <button onclick="getAvailable()">Get Available Products</button>
<script>
    function successHandler (result) {
        alert('successhandler');
        var strResult = "";
        if(typeof result === 'object') {
            strResult = JSON.stringify(result);
        } else {
            strResult = result;
        }
        alert("SUCCESS: \r\n"+strResult );
    }

    function errorHandler (error) {
        alert("ERROR: \r\n"+error );
    }

    // Click on init button
    function init(){
        // Initialize the billing plugin
        //myOwnKeyRSABase64App FROM GOOGLE DEVELOPERS CONSOLE
        inappbilling.init(successHandler, errorHandler, {showLog:true, key: 'myOwnKeyRSABase64App'});
    }

    // Click on purchase button
    function buy(){
        // make the purchase
        inappbilling.buy(successHandler, errorHandler,"gas");
    }

    // Click on ownedProducts button
    function ownedProducts(){
        // Initialize the billing plugin
        inappbilling.getPurchases(successHandler, errorHandler);

    }

    // Click on Consume purchase button
    function consumePurchase(){
        inappbilling.consumePurchase(successHandler, errorHandler, "gas");
    }

    // Click on subscribe button
    function subscribe(){
        // make the purchase
        inappbilling.subscribe(successHandler, errorHandler,"infinite_gas");

    }

    // Click on Query Details button
    function getDetails(){
        // Query the store for the product details
        inappbilling.getProductDetails(successHandler, errorHandler, ["gas","infinite_gas"]);

    }

    // Click on Get Available Products button
    function getAvailable(){
        // Get the products available for purchase.
        inappbilling.getAvailableProducts(successHandler, errorHandler);
    }
</script>

</body>
</html>
jamminjames commented 8 years ago

I would like to get info on this as well. If it can be installed via the remote Phonegap Build, that would be awesome.

YodasWs commented 8 years ago

You guys need to either switch to a fork of this plugin:

<gap:plugin name="com.mcm.plugins.androidinappbilling" version="3.0.6" />

or add your BILLING_KEY:

<gap:plugin name="com.smartmobilesoftware.inappbilling">
    <param name="BILLING_KEY" value="MIIBIjANBgk...AQAB" />
</gap:plugin>
jamminjames commented 8 years ago

Thanks for the reply, YodasWs. So, am I to understand that if I use <gap:plugin name="com.mcm.plugins.androidinappbilling" version="3.0.6" /> in the config.xml file, PhoneGap Build will install the plugin in such a way as to solve the problem with Google Play? Where does the billing key go in that case?

Do we include the info in the plugin.xml file manually anywhere in a PhoneGap Build install, or does that happen automatically? I notice there's a spot for the billing key in that file.