I am implementing subscription billing using the Version 3 Billing API. After the payment dialog has closed (payment succeeded), control is returned back to my activity
Calling method
String payload = UUID.randomUUID().toString();
bundle = mService.getBuyIntent(3, getPackageName(), mProduct, "subs", payload);
int responseCode = bundle.getInt("RESPONSE_CODE");
if (responseCode == 0) {
PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
} else if (responseCode == 1) {
mErrorMessage.setText(getResources().getString(R.string.purchase_cancelled));
mErrorMessage.setVisibility(View.VISIBLE);
} else if (responseCode == 7) {
mErrorMessage.setText(getResources().getString(R.string.payment_twice));
mErrorMessage.setVisibility(View.VISIBLE);
} else {
mErrorMessage.setText(getResources().getString(R.string.payment_general_error));
mErrorMessage.setVisibility(View.VISIBLE);
}
My activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
// Null
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"
}
}
The problem is that the purchaseData string is null. This might be because I have already purchased this subscription ( a million times when testing ) - and that I should have checked with getPurchases() first.
Is it known for purchases to "go through - apparently with success", if the user tries to pay when he or she is 1) a current subscriber, or 2) in the period after cancelleation but before the service expires?
I had the same problem and I found out that I was using ITEM_TYPE_SUBS = "subs"
instead of ITEM_TYPE_INAPP = "inapp"
.
When I put the right parameter in, it worked as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With