Question

How to cancel a user's all subscriptions without the URL?

  • 10 July 2024
  • 2 replies
  • 52 views

Badge

I’m trying to find how to delete a subscription. And I want to do it without the URL Technique like the app provides a link to user which takes the user to Google App Store and from there the user can cancel the subscription.

The case that I have is that when a user deletes his account we have to remove or cancel all his subscription as well as delete all his data from RevenueCat behind the scenes. And I can’t simply call the DELETE API ENDPOINT because It won’t delete the subscription data, and I have to first cancel subscriptions then, have to call the DELETE endpoint.


And for that I was searching I found the following  `API End point`
`https://api.revenuecat.com/v1/subscribers/{app_user_id}/subscriptions/{store_transaction_identifier}/cancel`

However this endpoint seems to requires a parameter named `store_transaction_identifier`. 
Then I searched how to get that. And the answer that I got that `You can find the store_transaction_id, from Webhook`.

Now I had to find the RevenueCat’s webhook, Which I wasn’t able to find and not able to find the variable. 


Anybody know how to get that `store_transaction_id`? 


Now it has become a pain just to cancel a subscription, that shouldn’t  be…

I need a way to cancel a user’s subscriptions from Back-end just by hitting an API Endpoint.

OR It would be nice If We just get an Endpoint where we just provide the user_id and ask revenue cat to delete all the subscriptions in just one go...


2 replies

Userlevel 3
Badge +5

Hi, You can access the store_transaction_id for a subscription via the Get or Create Customer Endpoint. Here is our documentation on webhooks, although, in your use case, I don’t believe that they would be useful and you should make a call to the endpoint instead. You can also access the store transaction identifier via the data in our Scheduled Data Exports.

Badge

@wes_clark In which section of response from Get or Create Customer Endpoint , I’m going to find the  store_transaction_id ?.

From this Customer Endpoint GET https://api.revenuecat.com/v1/subscribers/{app_user_id}, I am not able to find the store_transaction_id from the Response Object.

This is the response Object from Docs
------>
{
  "request_date": "2019-07-26T17:40:10Z",
  "request_date_ms": 1564162810884,
  "subscriber": {
    "entitlements": {
      "pro_cat": {
        "expires_date": null,
        "grace_period_expires_date": null,
        "product_identifier": "onetime",
        "purchase_date": "2019-04-05T21:52:45Z"
      }
    },
    "first_seen": "2019-02-21T00:08:41Z",
    "management_url": "https://apps.apple.com/account/subscriptions",
    "non_subscriptions": {
      "onetime": [
        {
          "id": "cadba0c81b",
          "is_sandbox": true,
          "purchase_date": "2019-04-05T21:52:45Z",
          "store": "app_store"
        }
      ]
    },
    "original_app_user_id": "XXX-XXXXX-XXXXX-XX",
    "original_application_version": "1.0",
    "original_purchase_date": "2019-01-30T23:54:10Z",
    "other_purchases": {},
    "subscriptions": {
      "annual": {
        "auto_resume_date": null,
        "billing_issues_detected_at": null,
        "expires_date": "2019-08-14T21:07:40Z",
        "grace_period_expires_date": null,
        "is_sandbox": true,
        "original_purchase_date": "2019-02-21T00:42:05Z",
        "ownership_type": "PURCHASED",
        "period_type": "normal",
        "purchase_date": "2019-07-14T20:07:40Z",
        "refunded_at": null,
        "store": "app_store",
        "unsubscribe_detected_at": "2019-07-17T22:48:38Z"
      },
      "onemonth": {
        "auto_resume_date": null,
        "billing_issues_detected_at": null,
        "expires_date": "2019-06-17T22:47:55Z",
        "grace_period_expires_date": null,
        "is_sandbox": true,
        "original_purchase_date": "2019-02-21T00:42:05Z",
        "ownership_type": "PURCHASED",
        "period_type": "normal",
        "purchase_date": "2019-06-17T22:42:55Z",
        "refunded_at": null,
        "store": "app_store",
        "unsubscribe_detected_at": "2019-06-17T22:48:38Z"
      },
      "rc_promo_pro_cat_monthly": {
        "auto_resume_date": null,
        "billing_issues_detected_at": null,
        "expires_date": "2019-08-26T01:02:16Z",
        "grace_period_expires_date": null,
        "is_sandbox": false,
        "original_purchase_date": "2019-07-26T01:02:16Z",
        "ownership_type": "FAMILY_SHARED",
        "period_type": "normal",
        "purchase_date": "2019-07-26T01:02:16Z",
        "refunded_at": null,
        "store": "promotional",
        "unsubscribe_detected_at": null
      }
    }
  }
}

<----------

 

Reply