Open kamiyo opened 5 years ago
This looks like it's written by a professional software engineer :D
Here are the pros I see with approach B
Here are the pros I see with approach A
I personally prefer approach A, because of not having to store users' emails. Whatever security we put around probably won't be as good as Stripe's.
What do you think?
Yea that's my leaning, too. I just wish Stripe's API were a bit unified. You can use customers with orders and products and skus, but they're moving away from orders, which isn't compatible with their new checkout and payment intents. The only other way I can think of is to use their invoice API just to keep track of the items and the customer, but to not use their invoice API for actual collection. Then in Session store the Invoice ID in the client_reference_id
field. When the success webhook is called, you add the purchased items to the that customer's invoice. Then when we search for the customer's purchased PDFs, we essentially use the invoice as a ledger for the customer. What do you think about that?
Do invoices have an expiration date?
I think if you don't use their automatic workflow and don't manually delete it it'll be there.
Seems kinda hacky? I'm okay with starting with approach A, and then seeing how we can improve it if we want.
On Fri, Sep 13, 2019 at 7:41 AM Sean Chen notifications@github.com wrote:
I think if you don't use their automatic workflow and don't manually delete it it'll be there.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jasboys/sycpiano/issues/235?email_source=notifications&email_token=AAI4ZVDCXJODAER5F54O5Z3QJORATA5CNFSM4IWLYRBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6VHD3Y#issuecomment-531263983, or mute the thread https://github.com/notifications/unsubscribe-auth/AAI4ZVHBKXG34S2FJOXP47LQJORATANCNFSM4IWLYRBA .
-- Andrew Chen
Haha yea a bit. I mean storing the skus in the metadata portion also seems kind of hacky, but I guess less so. i wish you could store as an array of strings, but it only allows associative array, so we have to do sku0, sku1, ...
Let's go with A first then. 👍
I thought I would create a plan for implementing the shop. After reading the Stripe APIs and thinking about how to do it this is what I came up with.
Few considerations:
With that in mind, here are the things to do
Migrate the SKUs from Stripe API to internal DB. It seems from the direction the API is going, the Orders/Products/SKUs are being discouraged. Need to make a the following tables: Customer, Products(see below, Method B).Method A
Here's the shop flow:
payment_intent_data.receipt_email
, and the actual skus aspayment_intent_data.metadata
in a hashmap:stripe.redirectToCheckout
with the received session ID and the correctsuccessUrl
andcancelUrl
.checkout.session.completed
webhook.Here's the flow to retrieve previously purchased pdfs (not efficient, but since we're not tracking customer IDs to email:
customer=CustomerID
. Filter bystatus==='succeeded'
and reduce the metadata SKUs into an accumulating array. After all this is done, you should have an array with the SKUs to fetch; Fetch the list of SKUs from Stripe to get the filename (is this stored in the metadata?).Method B
Need Customer and Product tables, with each Customer having many Products. Customer's fields should have ID (we'll just use the Stripe generated ID), email, and hasMany association to Products. Products should have fields with ID, name, description, price, currency, image, filename.
Differences bolded.
Here's the shop flow:
payment_intent_data.receipt_email
, and the actual Product IDs aspayment_intent_data.metadata
in a hashmap:stripe.redirectToCheckout
with the received session ID and the correctsuccessUrl
andcancelUrl
.checkout.session.completed
webhook.session.customer
, and the Products bought:session.payment_intent.metadata
. In internal DB, associate Customer with the bought Products.Here's the flow to retrieve previously purchased pdfs (not efficient, but since we're not tracking customer IDs to email:
Comments requested!