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 ?
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.
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
- – I created a POST endpoint on backend and linked it to Gumroad Ping API hook.
- – When server receives an API request, it updates all the data to a Postgres dB( Powered by Supabase in this case)
- – When i perform domain logic of the app , on backend i verify user’s tier and allowed permissions and accordingly proceed with the operation.
- – This ensures, User experience is smooth and No one can abuse system
You can also checkout blog by Faraz for code snippets