Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/post subscription #101

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/src/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios'
import Swal from 'sweetalert2'

const baseURL = 'https://nextmeal.herokuapp.com/api'
// const baseURL = 'http://localhost:3000/api'
// const baseURL = 'https://nextmeal.herokuapp.com/api'
const baseURL = 'http://localhost:3000/api'

// config an instance
const axiosInstance = axios.create({
Expand Down
10 changes: 1 addition & 9 deletions server/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ let userController = {
order: [['updatedAt', 'DESC']],
limit: 1
})

const tradeInfo = getTradeInfo(req.body.sub_price, req.body.sub_name, req.body.sub_description, req.user.email)
if (!subscription) {
const tradeInfo = getTradeInfo(req.body.sub_price, req.body.sub_name, req.body.sub_description, req.user.email)
subscription = await createSubscription(req, res, tradeInfo)
return res.status(200).json({ status: 'success', subscription, tradeInfo, message: 'Successfully create a subscription' })
}
Expand All @@ -192,17 +191,10 @@ let userController = {
}
// 曾經訂閱
if (expired || once) {
const tradeInfo = getTradeInfo(req.body.sub_price, req.body.sub_name, req.body.sub_description, req.user.email)
subscription = await createSubscription(req, res, tradeInfo)
return res.status(200).json({ status: 'success', subscription, tradeInfo, message: 'Successfully create a subscription' })
}
// 如果有訂單,但還沒付款,先產生新 trandeInfo 記得傳入 sn,如果選擇的方案不相同,修改方案
const tradeInfo = getTradeInfo(
subscription.sub_price,
subscription.sub_name,
req.body.sub_description,
req.user.email
)
subscription = await subscription.update({
sub_name: req.body.sub_name,
sub_price: req.body.sub_price,
Expand Down