dayhaysoos / use-shopping-cart

Shopping cart state and logic for Stripe
MIT License
913 stars 118 forks source link

feat: update checkoutSingleItem to support three types of input #259

Closed hideokamoto-stripe closed 2 years ago

hideokamoto-stripe commented 2 years ago

I found the TODO comment in this file.

// TODO : check on bug for sending product.id as price in stripe-middleware? https://github.com/dayhaysoos/use-shopping-cart/blob/master/use-shopping-cart/react/test/index.test.js#L602

And I probably found the way to resolve the issue, so I'd made this Pull Request.

Usage

Provide a price id as string

checkoutSingleItem('price_xxx')

{
  ...,
  lineItems: [{
    price: 'price_xxx',
    quantity: 1
  }]
}

Provide a object props includes a price id (and quantity)

checkoutSingleItem({
  price: 'price_xxx',
  quantity: 2
})

{
  ...,
  lineItems: [{
    price: 'price_xxx',
    quantity: 2
  }]
}

Provide a object props includes a sku id (and quantity)

checkoutSingleItem({
  sku: 'sku_xxx',
  quantity: 2
})

{
  ...,
  items: [{
    sku: 'price_xxx',
    quantity: 2
  }]
}

==

We can check the entire behavior in this file.

https://github.com/hideokamoto-stripe/use-shopping-cart/blob/feat/checkout-single-item/use-shopping-cart/react/test/index.test.js#L602-L724

Thanks!

netlify[bot] commented 2 years ago

πŸ‘· Deploy request for useshoppingcart pending review. Visit the deploys page to approve it

πŸ”¨ Explore the source changes: d934ea53ef3f90f9303bdecbbf626892e3431d61

dayhaysoos commented 2 years ago

Whoa, awesome! Going to take a look at this later today

dayhaysoos commented 2 years ago

Do you see this error when you run your tests or is this just my machine? Everything looks good to me otherwise, idk why this is a thing for me right now

error

hideokamoto-stripe commented 2 years ago

Well... I can see another warning, but does not failed...

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 0004-01-18 14 11 43
dayhaysoos commented 2 years ago

@hideokamoto-stripe I found which test is throwing this warning!

Screen Shot 2022-01-18 at 8 34 56 AM

I'm having a hard time trying to resolve this, though :( Any ideas on what it could be?

hideokamoto-stripe commented 2 years ago

Thanks! I found my mistake in this test code. I've fixed it and confirm to work well. https://github.com/dayhaysoos/use-shopping-cart/pull/259/commits/d934ea53ef3f90f9303bdecbbf626892e3431d61

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 0004-01-19 12 13 21

Thanks!

dayhaysoos commented 2 years ago

@all-contributors please add @hideokamoto-stripe for code

allcontributors[bot] commented 2 years ago

@dayhaysoos

I've put up a pull request to add @hideokamoto-stripe! :tada: