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

后端 未结 4 1109
挽巷
挽巷 2020-12-18 18:07

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 fin

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 18:49

    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

提交回复
热议问题