Skip to content

Commit

Permalink
[FEATURE] use required for env params
Browse files Browse the repository at this point in the history
  • Loading branch information
depresto committed May 11, 2023
1 parent 1f7d3a1 commit 06baf81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ecpay-invoice-sdk",
"version": "1.0.7",
"version": "1.0.8",
"description": "綠界發票 SDK",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
25 changes: 13 additions & 12 deletions src/ecpay-invoice.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ class EcpayInvoiceClient {
hashIV: string;

constructor(params: {
merchantId?: string;
hashKey?: string;
hashIV?: string;
env?: "sandbox" | "production";
merchantId: string;
hashKey: string;
hashIV: string;
env: "sandbox" | "production";
}) {
this.merchantId = params.merchantId ?? "2000132";
this.hashKey = params.hashKey ?? "ejCk326UnaZWKisg";
this.hashIV = params.hashIV ?? "q9jcZX8Ib9LM8wYk";
this.merchantId = params.merchantId;
this.hashKey = params.hashKey;
this.hashIV = params.hashIV;

this.apiEndpoint = (params.env ? params.env === "sandbox" : true)
? "https://einvoice-stage.ecpay.com.tw"
: "https://einvoice.ecpay.com.tw";
this.apiEndpoint =
params.env === "sandbox"
? "https://einvoice-stage.ecpay.com.tw"
: "https://einvoice.ecpay.com.tw";
}

private encryptPostData(params: { [key: string]: any }) {
Expand Down Expand Up @@ -85,7 +86,7 @@ class EcpayInvoiceClient {
public async revokeB2CInvoice(
InvoiceNo: string,
InvoiceDate: string,
Reason = ""
Reason: string
): Promise<EcpayResponse<RevokeB2CInvoiceResult>> {
return this.queryB2CApi("/B2CInvoice/Invalid", {
InvoiceNo,
Expand Down Expand Up @@ -118,7 +119,7 @@ class EcpayInvoiceClient {
public async revokeB2CAllowance(
InvoiceNo: string,
AllowanceNo: string,
Reason = ""
Reason: string
): Promise<EcpayResponse<RevokeB2CAllowanceResult>> {
return this.queryB2CApi("/B2CInvoice/AllowanceInvalid", {
InvoiceNo,
Expand Down

0 comments on commit 06baf81

Please sign in to comment.