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

梦想的初衷 提交于 2019-11-29 09:05:55

Update:
Inappbilling library 1.0 just released to make this easier.


Kumar Bibek has already answerd above: Still I am giving an explanation:

Hardcode the following debug options in the launch purchase flow to get the desired output.

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

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

The above will give these screens:

On clicking Buy.

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

Use these product IDs and you should get a fake card prompt in the purchase screen.

Reference:
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. 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.

iPhone developers/users do not have the VPN problem at all.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!