Skip to main content
Question

Stripe payment links


Forum|alt.badge.img

How do I link stripe payments through their payment links to a revenuecat user? I tried using the client_reference_id url param and link that in the revenuecat ui using the metadata field option but I do not think it is working.

This post has been closed for comments

4 replies

Forum|alt.badge.img

And follow up question while I’m here it says in your docs “Only Package Pricing and Standard Pricing subscription plans with per unit pricing are supported. Metered usage and tiers are currently not supported.” does this mean multiple quantities of the same subscription are supported in revenuecat like it is in stripe?


guilherme
RevenueCat Staff
Forum|alt.badge.img+1
  • RevenueCat Staff
  • 18 replies
  • April 10, 2025

Hey ​@michael-f34007,
 
Happy to help here!
 

michael-f34007 wrote:

How do I link stripe payments through their payment links to a revenuecat user? I tried using the client_reference_id url param and link that in the revenuecat ui using the metadata field option but I do not think it is working.

 

Regarding payment links and how to link them to a RevenueCat user, in essence we just need two items: the app_user_id, and the fetch_token (aka subscription ID for Stripe), and we need it to be sent explicitly to our API from your own server.
 
Typically, the flow is as follows:

  1. You direct your customers to your Stripe Checkout flow, and the user makes a purchase
  2. As Stripe's docs mention, Stripe sends the checkout.session.completedwebhook to your server
    1. At this time, we can't listen for this webhook directly on our end
  3. Your server receives the webhook from Stripe, and calls our POST /receipts endpoint according to step 5 of our guide https://www.revenuecat.com/docs/stripe#5-send-stripe-tokens-to-revenuecat
    1. This server can be a tiny web service - it just needs to consume a webhook from Stripe, and send a request to our API
  4. RevenueCat receives the purchase, and starts tracking the subscription/purchase status for the product
  5. When you identify users in the SDK with the same app user ID, they will have access to entitlements as would be expected with the Apple/App Store billing process

Do let me know if that makes sense and how you get going with it! 
 

michael-f34007 wrote:

And follow up question while I’m here it says in your docs “Only Package Pricing and Standard Pricing subscription plans with per unit pricing are supported. Metered usage and tiers are currently not supported.” does this mean multiple quantities of the same subscription are supported in revenuecat like it is in stripe?

 

As for your second point, if you are referring to being able to purchase a subscription multiple times then yes, that is possible indeed! But do let me know if you have a specific use case you need to validate.

--Gui from RevenueCat


Forum|alt.badge.img

For the payment links I found a way to track the Stripe payment without using a server as a middle man, I create the payment links dynamically. In revenuecat UI add the following:

 

 

And create the payment links using metadata to track the user ID (this code is in Flutter/dart):

  Future<String> createPaymentLink(
      {required String email,
      required String userId,
      required String productId}) async {
    // Stripe secret key (replace with your own in a real app, ideally stored securely)
    const String secretKeySandbox =
        'sk_test_...';
    // can only be used for creating payment links
    const String secretKeyProduction =
        'rk_live_...';

    String secretKey = secretKeyProduction;
    if (isSandbox) {
      secretKey = secretKeySandbox;
    }

    // Create Basic Authentication header
    String basicAuth = 'Bearer $secretKey';

    // Prepare request body as a map
    Map<String, String> body = {
      'line_items[0][price]': productId,
      'line_items[0][quantity]': '1',
      'after_completion[type]': 'redirect',
      'after_completion[redirect][url]': 'https://aac.qvoice.app',
      'subscription_data[metadata][revenuecat_user_id]': userId,
      'subscription_data[trial_period_days]': '30',
      'line_items[0][adjustable_quantity][enabled]': 'true',
    };

    try {
      // Send POST request to Stripe API
      var response = await http.post(
        Uri.parse('https://api.stripe.com/v1/payment_links'),
        headers: {
          'Authorization': basicAuth,
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: body,
      );

      // Handle the response
      if (response.statusCode == 200) {
        var data = jsonDecode(response.body);
        String url = '${data['url']}?prefilled_email=$email';
        return url;
      } else {
        print('Error creating payment link: ${response.statusCode}');
        print(response.body);
        return '';
      }
    } catch (e) {
      print('Exception occurred creating payment link: $e');
      return '';
    }
  }

 

For my second point I was referring to in Stripe you can Let customers adjust quantity of a subscription, I was not able to find a way to get this information in revenuecat so I had to use the Stripe API to handle Stripe subscription quantities:

 


guilherme
RevenueCat Staff
Forum|alt.badge.img+1
  • RevenueCat Staff
  • 18 replies
  • April 14, 2025

Hey ​@michael-f34007 ,

Thanks for sharing your setup! It seems that will work indeed - just a heads-up to double-check that purchases are being correctly sent from your side and showing up in your RevenueCat dashboard.

I mention this because I checked our logs and haven’t seen any events come through just yet! It’s worth confirming everything’s connected end-to-end!
 

michael-f34007 wrote:


For my second point I was referring to in Stripe you can Let customers adjust quantity of a subscription, I was not able to find a way to get this information in revenuecat so I had to use the Stripe API to handle Stripe subscription quantities:

 

 

Regarding subscription quantities, adjusting the quantity of a subscription isn’t natively supported in RevenueCat. While we can track Stripe subscriptions, we don’t currently support quantity-based subscriptions so, if a customer updates the quantity in Stripe, that change won't be reflected on the RevenueCat side.

That said, we do read the quantity and unit_amount from the Stripe receipt, and the total price we show should already account for that.

Let us know if we can help troubleshoot or clarify any part of this and thanks once again for sharing all these details!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings