【问题标题】:in-app billing with phonegap for android app适用于 Android 应用的 phonegap 应用内计费
【发布时间】:2014-05-15 13:49:05
【问题描述】:

我正在开发一个 android phonegap 应用程序,我想在其中使用应用程序计费。我安装了phonegap billing plugin,它运行良好。你能帮我用一个链接让它正常工作吗?

例如,这里是脚本代码:

<script >
function successHandler (result) {
    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
    inappbilling.init(successHandler, errorHandler, {showLog:true});
}

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

// 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, "good_id");
}

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

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

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

例如,我需要它来工作 -

<a href="good.html" id='good' data-ignore="true">Good</a>

首先点击链接后,我将能够在链接到页面之前付款。 谢谢。对不起我的英语不好。

【问题讨论】:

    标签: android cordova phonegap-plugins billing


    【解决方案1】:

    我不确定我是否明白你想要什么,你的英语比我的差。但是,如果您只想在点击时和重定向后启动购买,您可以使用 onclick 事件和 window.location.replace :

    <a href="good.html" id='good' data-ignore="true" onclick="buy()" >Good</a>
    
    // Click on purchase button
    function buy(){
    // make the purchase
        inappbilling.buy(successHandler, errorHandler, "good_id");
        return false;
    }
    

    然后添加 window.location.replace('yourlinkpage');在你的成功处理程序上

    但也许输入提交应该更合适?

    【讨论】:

      猜你喜欢
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-06
      • 2011-10-19
      相关资源
      最近更新 更多