Integrating iap.dev Android SDK with the Doggie Treats App
This guide will help you integrate the iap.dev SDK into your existing Doggie Treats Android app.
Step 1: Update Gradle
In your app's build.gradle
file, add the iap.dev SDK:
dependencies {
def iapDevSdkVersion = '1.0.+'
debugImplementation "dev.iap:android-billing-sdk-drop-in:${iapDevSdkVersion}"
releaseImplementation "dev.iap:android-billing-sdk-no-op:${iapDevSdkVersion}"
// Keep your existing Google Play Billing Library dependency
releaseImplementation 'com.android.billingclient:billing:5.0.0'
}
Step 2: Initialize the SDK
In your main Activity or Application class, add the iap.dev SDK initialization:
import dev.iap.android.IapDev;
import dev.iap.android.IapDevConfiguration;
public class DoggieTreatsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doggie_treats);
// Initialize iap.dev SDK
IapDev.setup(new IapDevConfiguration.Builder("YOUR_CLIENT_KEY", "YOUR_CLIENT_SECRET")
.environment(IapDevConfiguration.Environment.DEBUG)
.build(), this.getApplicationContext());
// Your existing initialization code...
}
}
Replace YOUR_CLIENT_KEY
and YOUR_CLIENT_SECRET
with the values from your iap.dev console.
Step 3: Update Your Existing IAP Logic
Replace your current BillingClient
instantiation with:
BillingClient billingClient = IapDevBillingClientBuilder.newBuilder(context)
.setListener(purchasesUpdatedListener)
.enablePendingPurchases()
.build();
This ensures that the iap.dev SDK intercepts and handles IAP requests in debug builds.
Step 4: Test Your Integration
Run your app in debug mode. You should see the app homescreen with a green "Connected" status and "Ready to Buy!" purchase status.
Initiate a purchase by clicking "Buy now for $9.99!". You'll see the purchase screen:
Tap "BUY" and confirm the purchase. You'll see a success screen:
Tap "GOT IT" to complete the process. You'll see a visual confirmation:
Verify the transaction in your iap.dev console under "Product Purchases":
You should see a new line item for the purchase:
Remember to thoroughly test your integration before releasing to your users. The iap.dev SDK allows you to test purchases without actual charges in debug mode.
For more detailed information and advanced features, please refer to the iap.dev documentation.