简体   繁体   English

使用虚拟信用卡凭证测试 Android 市场应用内计费

[英]Testing Android Market in-app billing with dummy credit card credentials

I have configured an Android application to use the in-app billing module as documented at: http://developer.android.com/guide/market/billing/index.html I have configured an Android application to use the in-app billing module as documented at: http://developer.android.com/guide/market/billing/index.html

It works fine when tested using the UK development team's accounts which have real credit cards associated with them.当使用英国开发团队的账户进行测试时,它工作正常,这些账户与他们关联的真实信用卡。 However, part of my development team is based in China, and as Google Billing does not operate in China, they are unable to test the billing functionality.但是,我的部分开发团队位于中国,由于 Google Billing 不在中国运营,他们无法测试计费功能。

Understandably the team is uncomfortable sharing personal card details, or personal account information with others.可以理解的是,团队不愿意与他人分享个人卡详细信息或个人帐户信息。 Does anybody know a work around for this?有人知道解决这个问题吗? While in testing, can dummy card numbers be associated with the account?在测试时,虚拟卡号可以与帐户关联吗?

I know this works in the merchant sandbox ( http://code.google.com/apis/checkout/developer/Google_Checkout_Basic_HTML_Sandbox.html ) but I can't seem to find an equivalent for Android billing testing. I know this works in the merchant sandbox ( http://code.google.com/apis/checkout/developer/Google_Checkout_Basic_HTML_Sandbox.html ) but I can't seem to find an equivalent for Android billing testing.

Any help/guidance/support would be appreciated here.任何帮助/指导/支持将在这里不胜感激。 The China team is focused on a lot of the modules related to the post-purchase experience and this will be seriously compromised if we cannot find a workaround.中国团队专注于很多与售后体验相关的模块,如果我们找不到解决方法,这将受到严重影响。

Thanks!谢谢!


Update:更新:
Inappbilling library 1.0 just released to make this easier.刚刚发布的Inappbilling 库 1.0使这更容易。


Kumar Bibek has already answerd above: Still I am giving an explanation: Kumar Bibek 已经在上面回答了:我仍然在给出解释:

Hardcode the following debug options in the launch purchase flow to get the desired output.在启动购买流程中硬编码以下调试选项以获得所需的 output。

  • android.test.purchased android.test.purchased
  • android.test.canceled android.test.canceled
  • android.test.refunded android.test.refunded
  • android.test.item_unavailable* android.test.item_unavailable*

    mHelper.launchPurchaseFlow(Activity.this, "android.test.purchased", 1000, mPurchaseFinishedListener, payload); mHelper.launchPurchaseFlow(Activity.this, "android.test.purchased", 1000, mPurchaseFinishedListener, payload);

The above will give these screens:以上将给出这些屏幕:

在此处输入图像描述

On clicking Buy.点击购买。

在此处输入图像描述

  • android.test.purchased android.test.purchased
  • android.test.canceled android.test.canceled
  • android.test.refunded android.test.refunded
  • android.test.item_unavailable android.test.item_unavailable

Use these product IDs and you should get a fake card prompt in the purchase screen.使用这些产品 ID,您应该会在购买屏幕上看到假卡提示。

Reference:参考:
https://developer.android.com/google/play/billing/billing_testing.html#billing-testing-static https://developer.android.com/google/play/billing/billing_testing.html#billing-testing-static

In order to close this thread - the solution that I eventually wound up deploying was one provided by TEK.为了关闭这个线程——我最终部署的解决方案是由 TEK 提供的。 I procured some prepaid credit cards and attached them to test accounts.我购买了一些预付信用卡并将它们附加到测试帐户。 It mitigated risk and allowed for our developers to use the accounts.它降低了风险并允许我们的开发人员使用这些帐户。

I should point out that the developers in China also had to VPN out of China in order to pull the market billing dialog up.我应该指出,中国的开发人员也不得不将 VPN 移出中国,以拉动市场计费对话。

iPhone developers/users do not have the VPN problem at all. iPhone 开发者/用户根本没有 VPN 问题。

Thanks, Kaiesh谢谢,凯什

As answered above by other fellows I was able to do testing of the application by launching this peace of code in my activity正如上面其他研究员所回答的那样,我能够通过在我的活动中启动这种和平的代码来测试应用程序

 public class PurchaseTestingActivity extends AppCompatActivtiy implements BillingProcessor.IBillingHandler {

    ........
  purchaseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean isAvailable = BillingProcessor.isIabServiceAvailable(PrivateAndPublicCardHoldScreen.this);
            if (isAvailable) {
                       BillingProcessor bp = new BillingProcessor(this, "YOUR LICENSE KEY FOR THIS APPLICATION", this);
             /// this is the actually product 
//                    bp.purchase(PrivateAndPublicCardHoldScreen.this, "upgrade_to_premium");

      //// for testing purposes  
                bp.purchase(PrivateAndPublicCardHoldScreen.this, "android.test.purchased");
            }else{
                Toast.makeText(PrivateAndPublicCardHoldScreen.this, "Your device is not supported, please contact us.", Toast.LENGTH_LONG).show();
            }
        }
    });

  ..........

   @Override
public void onProductPurchased(String productId, TransactionDetails details) {
    /// handle your app after purchases done

}

@Override
public void onPurchaseHistoryRestored() {

}

@Override
public void onBillingError(int errorCode, Throwable error) {

}

@Override
public void onBillingInitialized() {

}


 }

PS: I have used this library for Implementation of In App purchases A lightweight implementation of Android In-app Billing Version 3 PS:我已经使用这个库来实现应用内购买Android 应用内计费版本 3 的轻量级实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM