Skip to content

Commit d27609b

Browse files
author
Simen Li
committed
bump to v0.2.0
1 parent 20df78b commit d27609b

16 files changed

+173
-85
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
A production-ready 綠界全方位金流(ECPay All-In-One, AIO) SDK for Node.js with TypeScript Support
44

55
[![build](https://github.com/simenkid/node-ecpay-aio/actions/workflows/build.yml/badge.svg)](https://github.com/simenkid/node-ecpay-aio/actions/workflows/build.yml)
6-
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/simenkid/6cd8ec3f4115bc7b0fc0cb646da2dd77/raw/d473b387740594dc486c5b8032ad8ba7adb7b91b/node-ecpay-aio__heads_main.json)
6+
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/simenkid/6cd8ec3f4115bc7b0fc0cb646da2dd77/raw/37458fd300efcea7ef2d3adbc4598e47a76a34d9/node-ecpay-aio__heads_main.json)
77
[![npm](https://img.shields.io/npm/v/node-ecpay-aio.svg?cacheSeconds=3600)](https://www.npmjs.com/package/node-ecpay-aio)
88
[![npm](https://img.shields.io/npm/l/node-ecpay-aio.svg?cacheSeconds=3600)](https://github.com/simenkid/node-ecpay-aio/blob/main/LICENSE)
99
[![node version](https://img.shields.io/node/v/node-ecpay-aio)](https://img.shields.io/node/v/node-ecpay-aio)
@@ -65,3 +65,7 @@ npm install --save node-ecpay-aio
6565
## License
6666

6767
Licensed under [MIT](https://github.com/simenkid/node-ecpay-aio/blob/main/LICENSE).
68+
69+
<br />
70+
<br />
71+
<br />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-ecpay-aio",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "A production-ready ECPay AIO SDK for Node.js with TypeScript support.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/__tests__/Merchant.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
TradeV2Query,
2020
FundingReconDetailQuery,
2121
} from '../feature/Query';
22-
2322
import { CreditCardPeriodAction, DoAction } from '../feature/Action';
2423
import { ECPayServiceUrls } from '../config';
2524
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from './test_setting';

src/__tests__/Payment.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ts-nocheck
2-
32
import { Merchant } from '../feature/Merchant';
43
import { CreditOneTimePayment } from '../feature/Payment';
54
import { TEST_MERCHANT_CONFIG } from './test_setting';

src/__tests__/payments/ALLPayPayment.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-nocheck
22
import { Merchant } from '../../feature/Merchant';
33
import { ALLPayment } from '../../feature/Payment';
4+
import { getCurrentTaipeiTimeString } from '../../utils';
45
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
56

67
describe('AndroidPayment: Check Params Types', () => {
@@ -119,3 +120,22 @@ describe('AndroidPayment: Check Params Types', () => {
119120
}).toThrowError('must be less than or equal to 999');
120121
});
121122
});
123+
124+
describe('ALLPayment: Redirect Post Form', () => {
125+
const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
126+
127+
const baseParams: BasePaymentParams = {
128+
MerchantTradeNo: `nea${getCurrentTaipeiTimeString({ format: 'Serial' })}`,
129+
MerchantTradeDate: getCurrentTaipeiTimeString(),
130+
TotalAmount: 999,
131+
TradeDesc: 'node-ecpay-aio testing order for ALLPayment',
132+
ItemName: 'test item name',
133+
};
134+
135+
test('Checkout with ', async () => {
136+
const payment = merchant.createPayment(ALLPayment, baseParams, {});
137+
138+
const html = await payment.checkout();
139+
expect(html.startsWith('<form id="_form_aio_checkout"')).toBe(true);
140+
});
141+
});

src/__tests__/payments/ATMPayment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//@ts-nocheck
22
import { Merchant } from '../../feature/Merchant';
33
import { ATMPayment } from '../../feature/Payment';
4-
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
54
import { getCurrentTaipeiTimeString } from '../../utils';
5+
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
66

77
const MERCHANT_CONFIG_ASYNC = {
88
...TEST_MERCHANT_CONFIG,

src/__tests__/payments/CreditDividePayment.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-nocheck
22
import { Merchant } from '../../feature/Merchant';
33
import { CreditDividePayment } from '../../feature/Payment';
4+
import { getCurrentTaipeiTimeString } from '../../utils';
45
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
56

67
describe('CreditDividePayment: Check Params Types', () => {
@@ -24,3 +25,24 @@ describe('CreditDividePayment: Check Params Types', () => {
2425
}).toThrowError('must be one of');
2526
});
2627
});
28+
29+
describe('CreditDividePayment: Redirect Post Form', () => {
30+
const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
31+
32+
const baseParams: BasePaymentParams = {
33+
MerchantTradeNo: `nea${getCurrentTaipeiTimeString({ format: 'Serial' })}`,
34+
MerchantTradeDate: getCurrentTaipeiTimeString(),
35+
TotalAmount: 999,
36+
TradeDesc: 'node-ecpay-aio testing order for CreditDividePayment',
37+
ItemName: 'test item name',
38+
};
39+
40+
test('Checkout with ', async () => {
41+
const payment = merchant.createPayment(CreditDividePayment, baseParams, {
42+
CreditInstallment: '3',
43+
});
44+
45+
const html = await payment.checkout();
46+
expect(html.startsWith('<form id="_form_aio_checkout"')).toBe(true);
47+
});
48+
});

src/__tests__/payments/CreditOneTimePayment.test.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-nocheck
22
import { Merchant } from '../../feature/Merchant';
33
import { CreditOneTimePayment } from '../../feature/Payment';
4+
import { getCurrentTaipeiTimeString } from '../../utils';
45
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
56

67
describe('CreditOneTimePayment: Check Credit Base Params Types', () => {
@@ -58,36 +59,25 @@ describe('CreditOneTimePayment: Check Credit Base Params Types', () => {
5859
});
5960
});
6061

61-
// describe('CreditOneTimePayment: html', () => {
62-
// const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
62+
describe('CreditOneTimePayment: Redirect Post Form', () => {
63+
const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
6364

64-
// const baseParams = {
65-
// MerchantTradeNo: 'nodeecpayaio0011',
66-
// MerchantTradeDate: '2021/05/22 11:20:20',
67-
// TotalAmount: 999,
68-
// TradeDesc: 'node-ecpay-aio testing order for CreditOneTimePayment',
69-
// ItemName: 'test item name',
70-
// };
65+
const baseParams: BasePaymentParams = {
66+
MerchantTradeNo: `nea${getCurrentTaipeiTimeString({ format: 'Serial' })}`,
67+
MerchantTradeDate: getCurrentTaipeiTimeString(),
68+
TotalAmount: 999,
69+
TradeDesc: 'node-ecpay-aio testing order for CreditOneTimePayment',
70+
ItemName: 'test item name',
71+
};
7172

72-
// test('Checkout with ', async () => {
73-
// const payment = merchant.createPayment(
74-
// CreditOneTimePayment,
75-
// baseParams,
76-
// {}
77-
// );
73+
test('Checkout with ', async () => {
74+
const payment = merchant.createPayment(
75+
CreditOneTimePayment,
76+
baseParams,
77+
{}
78+
);
7879

79-
// const html = await payment.checkout({
80-
// RelateNumber: 'rl-no',
81-
// TaxType: '1',
82-
// Donation: '0',
83-
// Print: '0',
84-
// InvoiceItemName: 'item1|item2',
85-
// InvoiceItemCount: '2|5',
86-
// InvoiceItemWord: '台|張',
87-
// InvoiceItemPrice: '100|50',
88-
// InvoiceRemark: '測試發票備註',
89-
// CustomerPhone: '0911111111',
90-
// });
91-
// console.log(html);
92-
// });
93-
// });
80+
const html = await payment.checkout();
81+
expect(html.startsWith('<form id="_form_aio_checkout"')).toBe(true);
82+
});
83+
});

src/__tests__/payments/CreditPeriodPayment.test.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Merchant } from '../../feature/Merchant';
33
import { CreditPeriodPayment } from '../../feature/Payment';
44
import { BasePaymentParamsSchema } from '../../schema';
5+
import { getCurrentTaipeiTimeString } from '../../utils';
56
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
67

78
const MERCHANT_CONFIG_PERIOD_CREDIT = {
@@ -336,12 +337,12 @@ describe('PeriodType="Y": Check Params Constraints', () => {
336337
});
337338
});
338339

339-
describe('CreditPeriodPayment: html', () => {
340+
describe('CreditPeriodPayment: Redirect Post Form', () => {
340341
const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
341342

342343
const baseParams: BasePaymentParams = {
343-
MerchantTradeNo: 'necacc0001',
344-
MerchantTradeDate: '2022/05/13 15:33:20',
344+
MerchantTradeNo: `nea${getCurrentTaipeiTimeString({ format: 'Serial' })}`,
345+
MerchantTradeDate: getCurrentTaipeiTimeString(),
345346
TotalAmount: 999,
346347
TradeDesc: 'node-ecpay-aio testing order for CreditPeriodPayment',
347348
ItemName: 'test item name',
@@ -355,19 +356,8 @@ describe('CreditPeriodPayment: html', () => {
355356
ExecTimes: 99,
356357
// PeriodReturnURL: 'https://ap.example.com/api',
357358
});
359+
358360
const html = await payment.checkout();
359-
// const html = await payment.checkout({
360-
// RelateNumber: 'rl-no-1',
361-
// TaxType: '1',
362-
// Donation: '0',
363-
// Print: '0',
364-
// InvoiceItemName: 'item1|item2',
365-
// InvoiceItemCount: '2|5',
366-
// InvoiceItemWord: '台|張',
367-
// InvoiceItemPrice: '100|50',
368-
// InvoiceRemark: '測試發票備註',
369-
// CustomerPhone: '0911111111',
370-
// });
371-
// console.log(html);
361+
expect(html.startsWith('<form id="_form_aio_checkout"')).toBe(true);
372362
});
373363
});

src/__tests__/payments/WebATMPayment.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ts-nocheck
22
import { Merchant } from '../../feature/Merchant';
33
import { WebATMPayment } from '../../feature/Payment';
4+
import { getCurrentTaipeiTimeString } from '../../utils';
45
import { TEST_MERCHANT_CONFIG, TEST_BASE_PARAMS } from '../test_setting';
56

67
describe('WebATMPayment: Check Params Types', () => {
@@ -13,3 +14,22 @@ describe('WebATMPayment: Check Params Types', () => {
1314
}).not.toThrowError();
1415
});
1516
});
17+
18+
describe('WebATMPayment: Redirect Post Form', () => {
19+
const merchant = new Merchant('Test', TEST_MERCHANT_CONFIG);
20+
21+
const baseParams: BasePaymentParams = {
22+
MerchantTradeNo: `nea${getCurrentTaipeiTimeString({ format: 'Serial' })}`,
23+
MerchantTradeDate: getCurrentTaipeiTimeString(),
24+
TotalAmount: 999,
25+
TradeDesc: 'node-ecpay-aio testing order for WebATMPayment',
26+
ItemName: 'test item name',
27+
};
28+
29+
test('Checkout with ', async () => {
30+
const payment = merchant.createPayment(WebATMPayment, baseParams, {});
31+
32+
const html = await payment.checkout();
33+
expect(html.startsWith('<form id="_form_aio_checkout"')).toBe(true);
34+
});
35+
});

0 commit comments

Comments
 (0)