Phase 2 - Discussion
See original GitHub issueSo far things have been great! What I believe should be the goal of Phase 2 is to make this library better support backend use cases of shopping cart libraries.
Event trigger functions:
This means stuff like on
and off
methods for almost every interaction with the cart:
onAddItem()
onIncrementItem()
onDecrementItem()
onSetItemQuantity()
onRemoveItem()
onClearCart()
onRedirectToCheckout()
(Should we have this??)
This will allow any developer who needs to update a back end to send the appropriate data to the database if the user is logged in.
Is there anything missing from here? Would love input especially from @thorsten-stripe
This issue is to decide on what needs to be done, after we have an agreed-upon list of to-dos, I will create issues for each task and add them to the road map. We should also open up another issue on the implementation details on this after.
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (11 by maintainers)
Top Results From Across the Web
A review of phase 2-3 clinical trial designs - PubMed
This article reviews phase 2-3 clinical trial designs, including their genesis and the potential role of such designs in treatment evaluation.
Read more >End of Phase 2 (EOP2) Meeting Guidance | ProPharma Group
Following your Phase 2 clinical trials, you will need to review and obtain agreement from the FDA on your study designs for Phase...
Read more >Bahamut(Ultimate) Phase 2 Discussion : r/ffxiv - Reddit
69 votes, 53 comments. Here's what I got for Phase 2. Check these out! \o/ ROTATION . Heavensfall Meteor Stream x4 Meteor Stream...
Read more >Review: 'Phase2' by The End Machine - Rock & Blues Muse
Phase2 starts off with a cool atmospheric and dramatic interlude titled “The Rising” that gives your ears a little over a minute to...
Read more >A review of phase 2–3 clinical trial designs - Biostatistics
discussion of the many scientific flaws in the conventional phase 2→phase 3 treatment evaluation process that motivate phase2–3 designs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wish I could take credit for this, but I’m just stealing validated concepts from others: https://firebase.google.com/docs/firestore/manage-data/add-data#set_a_document 😉 I’ll cite my sources going forward 👍
Updating
getCheckoutData
to get your options for your service’s APIhttps://github.com/dayhaysoos/use-shopping-cart/blob/199ca808a203ea9c976ab3500f65ccc4601e5c22/use-shopping-cart/src/util.js#L46
The idea behind this abstraction is that you can make a function in
util.js
’sgetCheckoutData
object that will take in thecart
and produce most if not all of the options that the service, such as Stripe, will need to go to or do a checkout. This function you create will need to match the name of your service as it is on thecart
object, forstripe
it’ll bestripe(cart) {/* your code */}
Updating
checkoutHandler
to recognize your service’s APIThen, inside of
checkoutHandler
you’ll need to modify it to recognize your provider. Right now we only have one, Stripe, so it looks like this:https://github.com/dayhaysoos/use-shopping-cart/blob/199ca808a203ea9c976ab3500f65ccc4601e5c22/use-shopping-cart/src/util.js#L75
When you write yours it might look like this:
My oops, necessary fix before it’ll work:
Then, as I forgot to do this in development myself, you’ll need to change this line: https://github.com/dayhaysoos/use-shopping-cart/blob/199ca808a203ea9c976ab3500f65ccc4601e5c22/use-shopping-cart/src/util.js#L97
To say:
Updating a “checkout handler” with your service’s API
By this, I mean updating or creating a call to
checkoutHandler()
with the appropriate options and function for your service. In this instance, you’ll likely just be updatingredirectToCheckout()
andcheckoutSingleItem()
. The format is as follows:https://github.com/dayhaysoos/use-shopping-cart/blob/199ca808a203ea9c976ab3500f65ccc4601e5c22/use-shopping-cart/src/index.js#L126-L131
It needs the
cart
as the first as the first argument, then we can get to the options.In the options, the
mode
property determines what modes should be allowed for use with this function, therefore, if a mode not in this list is used, an error will be thrown. Note: this might be better refactored to be specific to each service but we’ll cross that bridge if we get there.Then below that, you can define a method/function that matches the
serviceProperty
name for your service,paypal
most likely. The parameters for this function areserviceObject, options, parameters
:serviceObject
- your service itself that you would use to do the checkout (stripe.redirectToCheckout()
)options
- you created this viagetCheckoutData
and if you’re incheckout-session
mode you’ll have asessionId
on it as well.parameters
- this is any extra options that you might need from the developer before you can go to the checkout, example below:https://github.com/dayhaysoos/use-shopping-cart/blob/199ca808a203ea9c976ab3500f65ccc4601e5c22/use-shopping-cart/src/index.js#L133-L139
Other things to do:
.d.ts
file.And don’t forget to make a Draft PR while you’re working on all this so it’s easier to track the progress 👍