Using Gumroad Ping API to Dynamically integrate Gumroad with your app

So, I wanted to setup a membership program for one of the side projects i was building SuperDMs. I checked a lot payment providers/platforms but couldn’t find one which i can leverage for a side project as all of them required some kind of legal entity association.

Which is where i thought of giving Gumroad a shot. The pricing model i wanted to implemented was supposed to be tier wise distribution strategy. So different tiers with different pricing and related features will be offered.

Gumroad already allows you to have that pricing model. But the main concern was, if i can make it dynamic. What i mean by dynamic ?

Once a user purchases a product , app should get to know immediately and should be able to upgrade user’s tier without letting user do anything extra (no refresh, logout login hassles)

While i was researching it, one of my fellow dev pointed me to Gumroad ping API. And that is exactly what i wanted. What does Gumroad ping API enable for you ?

  • When an order is placed on Gumroad’s payment page, it will trigger an API and send all payment and product related details as part of that API’s payload.
  • The API path can be defined by user. It could be anything but should be POST request.

What next ?

So this is what Gumroad gives you, but this has to be handled by some custom server that user should create to handle this incoming POST request.

Post request body will have these parameters

{
  "seller_id": "2-X8GHFaL0qLyzuSriD%3D",
  "product_id": "r4qDRsQVn3U16i_2iNJcjA%3D%3D",
  "product_name": "SuperDMs%20Subscription",
  "permalink": "superdms",
  "product_permalink": "https%3A%2F%ms",
  "short_product_id": "EqHa",
  "email": "superdmsapp%40gmail.com",
  "price": "4900",
  "gumroad_fee": "471",
  "currency": "usd",
  "quantity": "1",
  "discover_fee_charged": "false",
  "can_contact": "true",
  "referrer": "https%3A%2F%2Fapp.gumroad.com%2F",
  "order_number": "124214",
  "sale_id": "asfas",
  "sale_timestamp": "2021-12-04T08%3A38%3A26Z",
  "purchaser_id": "3443251",
  "subscription_id": "sfasfasf%3D%3D",
  "variants": {
    "Tier": "Influencer"
  },
  "test": "true",
  "ip_country": "India",
  "recurrence": "monthly",
  "is_gift_receiver_purchase": "false",
  "refunded": "false",
  "disputed": "false",
  "dispute_won": ""
}

Once you expose an endpoint on your server, your handler can literally handle the data anyway you want to implement it.

Also check :   8 Beginner Coding Tips That Will Come in Handy

In my case i just wanted to update or set user’s tier. But it can be leveraged for different use cases such as :

  •  Sending notifications to user about payments(SMS, Whatsapp etc)
  •  Creating user accounts on server side
  •  Sending them welcome messages
  •  Doing Giveaways to delivering assets(creatives, PDFs etc)
  •  Triggering any other automated integrations

Let me briefly talk about how i did setup of things for SuperDMs:

Architecture diagram

  1. – I created a POST endpoint on backend and linked it to Gumroad Ping API hook.
  2. – When server receives an API request, it updates all the data to a Postgres dB( Powered by Supabase in this case)
  3. – When i perform domain logic of the app , on backend i verify user’s tier and allowed permissions and accordingly proceed with the operation.
  4. – This ensures, User experience is smooth and No one can abuse system

You can also checkout blog by Faraz for code snippets

Leave a Comment