Recently Google introduces base plans to subscriptions. Base plans are used to introduce different billing period (you end up with single subscription and couple of base plans for example: monthly, weekly, yearly) https://support.google.com/googleplay/android-developer/answer/12154973?hl=en
When I verify subscription on backend I would like to know which base plan user selected but I cannot find any way to get that. Previously I was getting all necessary informations from:
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions
when Google introduced Base plans they also released purchases.subscriptionsv2:
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2
but both only returns productId which is subscription id and no base plan id. Any idea how to get that with service account authentication?
On the other hand I can see on Google Play Console under order details productId and selected base plan, so I know subscription is configured correctly
Google added new field offerDetails with basePlanId, offerId and offerTags into lineItems (https://developer.android.com/google/play/billing/compatibility#subscriptionpurchasev2-fields). Fields not documented yet in https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2, but already come in response.
Related
There are two endpoints in Google Play Developer API providing information about the subscription purchased by the user (depending on the purchase token) - purchases.subscriptions and purchases.subscriptionsv2. What is the proper way (and does it even exist?) to link that information with the corresponding subscription from Google Play Console, including the concrete base plan and offer?
v1 request doesn't contain any subscription identifiers, v2 request contains lineItems[].productId, which refers to the whole subscription. But none contain any information about base plans or offers, which were used to make the current purchase.
The second and smaller part of the question is where are located purchase price currency and amount in the v2 endpoint, which were available in the v1 endpoint?
Looks like Google has fixed this problem in the last API update and now there are basePlanId and offerId fields in OfferDetails in purchases.subscriptionsv2 request.
I am using the Google Play Billing Library 5 and have a subscription product with different base plans.
When processing the purchases in the PurchasesUpdatedListener or in the callback of queryPurchasesAsync, I receive a list of Purchase objects which contain inter alia the product IDs, purchase time and whether it's auto-renewing.
But how do I know which base plan was selected by the user, and when it expires?
The PurchaseHistoryRecord returned from queryPurchaseHistoryAsync also seems not to contain this info.
I know the Play Developer API returns the expiry time
with purchases.subscriptionsv2.get, but is the inconvenience of using the API directly necessary?
The conclusion I am coming to is that it is best to ignore the whole multiple base plans feature.
Create the subscriptions individually instead so you have
Silver_Plan_Monthly --> Silver_Monthly_Base --> Silver_monthly_free_trial_offer.
Then a separate subscription.
Silver_Plan_Yearly --> Silver_Yearly_Base --> Silver_yearly_free_trial_offer.
And so on for however many subscription levels you want Silver, Gold, Platinum etc.
This way when you get the users purchases you can immediately tell what sub/level/renewal period they bought by the productId which will be the subscription name (Silver_Plan_Monthly).
This is annoying in having to create all these subs but the billing library doesn't give enough info otherwise.
And you should be able to now easily upgrade/downgrade user between these levels and the billing periods.
I have an app with products, all ships I save in my cloud, today I checked the log and saw two differents order id, and in wallet/merchant not have that order yet.
So my question is:
Is rigth the order Id?
How long time usually delay to show order in wallet?
Default order ids I got: (2015/03/11)
GPA.1355-6245-00X8-05X6X
GPA.1375-4305-10X8-X3807
GPA.1367-7671-943X-3X336
Today I got thats: (2015/07/11) Today
4496482184183757633.6602695480X6175X
1206201909101041727.52364XX181X38496
Any one know?
Obs: The "X" in orders is only to hidden the real number
Google recently changed orderid format. I am not sure if you're testing in sandbox mode or production. For sandbox mode, order ids might not be correct, and even for production mode, there might be a bug.
For test mode, Google recommends to use purchaseToken
You can use the purchaseToken field to identify test purchases.
I think for production too you should use purchase token instead of orderId to identify purchases till we have a better support for new order ids.
EDIT
You can use Purchases.subscriptions: get API in the backend to check if purchase is valid.
Checks whether a user's subscription purchase is valid and returns its
expiry time
All Purchases.subscriptions API methods (get, cancel etc.) require a purchase token instead of order id so you don't need to store order id.
I am building an app that I want to use Google in app billing for. Does Google track in-app purchase history for me, so that I can query history and get data, say, by date or by item, etc. Or must my app itself store user's purchase history on my own backend? Also, if you can please provide a link so I can verify this info.
For your question answer is both YES and NO Google will take care of all purchases based on product type. If you are using Non-consumable or Subscription based products Google will keep records, in other case if you are using Consumable products Google will keep it's record till your app consumes that product.
If your app sends a purchase request Google will associate it with primary gmail account registered on android device and will not allow to purchase same product twice.
NOTE:- If You are using IAB-2 then above product type and flow will slightly different
Non-consumable ** is known as **Managed Products
*Subscription* is same as Subscription
*Consumable* is known as Unmanaged products
In case of IAB-2 google will never keep record of Unmanaged products and it is your responsibility to keep records if you want.
For more details see below link to developer guide.
Developer guide
I currently am using the dungeons example to implement inApp purchase from google and for the most part seems to be working. I currently load the purchases into my database to store all purchases made by a given user the is is stored by a udid I get from the device this is done when I see the onPurchaseStateChange method returns PurchaseState.PURCHASED. I need to be able to map this to one of the following pieces of data either the Google order number our the company Order Number
exampled by this which is shown on the receipt that is sent to the customer.
Google order number: 4444555552219333 - XYZ Inc Order #66666633355555224444.3332214444224444
How can I do this. I can't find where this information is returned from google during the transaction.
Hopefully when I find out that the PurchaseState.PURCHASED is returned I also have the ability to get additional data that matched either of the order numbers with the same call but if I have to make another one I guess I could make the call at this point but I do not know when to make it or what to actually call.
Found while continuing to research for an answer:
When a user purchases an in-app item, Google Checkout assigns the transaction a unique and permanent order number. Google Play provides that order number to you at the conclusion of the purchase flow, as the value of the orderId field of the PURCHASE_STATE_CHANGED intent.
In your app, you can use the order number as a general-purpose identifier for the in-app purchase transaction. After the purchase, you can use the order number as a means of tracking the transaction in reconciliation reports and for customer support.
The order number itself is a string consisting of numbers only, with a format assigned and managed by Google Checkout.
For transactions dated 5 December 2012 or later, Google Checkout assigns a Merchant Order Number (rather than a Google Order Number) and reports the Merchant Order Number as the value of orderID. Here's an example:
"orderId" : "12999556515565155651.5565135565155651"
For transactions dated previous to 5 December 2012, Google checkout assigned a Google Order Number and reported that number as the value of orderID. Here's an example of an orderID holding a Google Order Number:
"orderId" : "556515565155651"
So by parsing the intent you can determine the specific order it is associated with and store it or use it to confirm purchases or other details