Solved

Promotional Entitlement Grant: is_sandbox set to false when created in a sandbox environment

  • 2 December 2021
  • 3 replies
  • 103 views

Badge +4
  • New Member
  • 2 replies

Repro Steps:

  1. Create a RevenueCat account with a sandbox and non-sandbox environment
  2. Create an entitlement in each environment with the identifier of “Membership” in both
  3. Navigate to the interactive docs (or you can do this in your own code if you already have it set up) (https://docs.revenuecat.com/reference#basic)
  4. Enter your api key for your sandbox environment and pass any user id to create a subscriber https://docs.revenuecat.com/reference#subscribers
  5. Try to grant them a promotional grant for that user id, the entitlement identifier of “Membership” and duration of “yearly” https://docs.revenuecat.com/reference#grant-a-promotional-entitlement
  6. Returned subscription entitlement shows is_sandbox: false
     

Returned subscription info (see is_sandbox: false). 

{"request_date":"2021-12-02T21:52:16Z","request_date_ms":1638481936210,"subscriber":{"entitlements":{"Membership":{"expires_date":"2022-12-02T21:52:15Z","grace_period_expires_date":null,"product_identifier":"rc_promo_Membership_yearly","purchase_date":"2021-12-02T21:52:15Z"}},"first_seen":"2021-12-01T23:31:42Z","last_seen":"2021-12-01T23:31:42Z","management_url":null,"non_subscriptions":{},"original_app_user_id":"40069562-8047-4893-ac0f-a2c50f1be9de","original_application_version":null,"original_purchase_date":null,"other_purchases":{},"subscriptions":{"rc_promo_Membership_yearly":{"billing_issues_detected_at":null,"expires_date":"2022-12-02T21:52:15Z","grace_period_expires_date":null,"is_sandbox":false,"original_purchase_date":"2021-12-02T21:52:15Z","period_type":"normal","purchase_date":"2021-12-02T21:52:15Z","store":"promotional","unsubscribe_detected_at":null}}}



I can’t see what I’m doing wrong and this seems like a bug to me. I got memberships hooked up fine  a year or so ago and am now adding in the ability to gift a membership. I have logic to check if sandbox flag is true when trying to process subscriptions in development and staging environments. This seems to be able to work fine in production but for testing I’d like the subscription to return is_sandbox true like the non-promotional subscriptions do.

icon

Best answer by cody 17 December 2021, 18:49

View original

3 replies

Badge +4

It looks like the title was updated to not include the word Bug -- I’m pretty sure this is a bug unless it’s specified somewhere in the docs that is_sandbox returns false when in sandbox for promotional entitlement grants.

Userlevel 6
Badge +8

Hey @REP! Sorry for the delay here, this got lost in our queue.

This is currently expected behavior- in RevenueCat, there is no concept of a sandbox user, only sandbox transactions, since a user ID can have both sandbox and production transactions associated with them. In this case, a promotional entitlement is considered to be ‘production’, and so the is_sandbox property is false. I’m going to add this to our backlog to improve our documentation around explaining this. Let me know if you have any other questions!

Badge +4

Hey @cody -- thanks for checking it out! I totally understand that there’s no concept of a sandbox user, but the promotional entitlement comes back as a subscription which can be classified as a sandbox transaction and is in other cases. But it sounds like the entitlement grant is actually a part of the user and not technically a subscription even if it’s returned in the subscriptions array. We’ve already created a workaround in our code to handle this type of subscription for testing locally and in production, but I definitely wanted to flag it since the behavior was not consistent with the other subscriptions we’d integrated in the past.

Reply