Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CYHFREDA authored Oct 16, 2024
1 parent f9b013d commit 9fda354
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,23 @@ async function sendLineMessage(userId, message) {
// LINE Pay API 配置
const channelID = '2006462420';
const channelSecret = '8c832c018d09a8be1738b32a3be1ee0a';

// 生成唯一的 ID 函數
const generateUniqueId = (prefix) => {
return `${prefix}_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
};
// 創建支付的 API
app.post('/api/create-payment', async (req, res) => {
const paymentData = {
amount: 1000,
currency: 'TWD',
orderId: 'ORDER_ID_' + Date.now(), // 確保這是唯一的訂單 ID
orderId: generateUniqueId('ORDER_ID'), // 生成唯一的訂單 ID
packages: [
{
id: 'PACKAGE_ID_' + Date.now(), // 確保這是唯一的套餐 ID
id: generateUniqueId('PACKAGE_ID'), // 生成唯一的套餐 ID
amount: 1000,
products: [
{
id: 'PRODUCT_ID_' + Date.now(), // 確保這是唯一的商品 ID
id: generateUniqueId('PRODUCT_ID'), // 生成唯一的商品 ID
name: '商品名稱',
quantity: 1,
price: 1000,
Expand Down

0 comments on commit 9fda354

Please sign in to comment.