mardi 19 avril 2022

Design pattern question: How to route App, Backend and Webhooks

I try to find out how to design my workflows.

Webhooks are quite handy. a.) So I got the idea, to directly create my customers in Stripe. The Rails backend app listens on customer.created webhook and creates the user with the Stripe provided payload.

b.) Regularly I would send form data to the Rails backend, and from there I create the customer at Stripe via their gem/library.

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│  Frontend   │    │   Backend   │    │  Webhooks   │
│   NextJS    │    │    Rails    │    │   Stripe    │
└─────────────┘    └─────────────┘    └─────────────┘
       │                  ▲                  ▲       
       │      create      │     API call     │       
       └─────user via ────┴─────creates ─────┘       
               form             customer             
                                                     
                      or either                          
                                                     
┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│  Frontend   │    │  Webhooks   │    │   Backend   │
│   NextJS    │    │   Stripe    │    │    Rails    │
└─────────────┘    └─────────────┘    └─────────────┘
       │                  ▲                  ▲       
       │                  │                  │       
       └─────create ──────┴────Then via ─────┘       
            customer           webhook               
           at Stripe            create          

What is the common way? Next->Rails->Stripe?

And why the Next->Stripe->Webhooks->Rails should be avoided?

Aucun commentaire:

Enregistrer un commentaire