@pax2pay/model-banking 0.1.119 → 0.1.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Authorization/Status.ts +4 -4
- package/Authorization/index.ts +26 -17
- package/dist/Authorization/Status.d.ts +1 -1
- package/dist/Authorization/Status.js +3 -3
- package/dist/Authorization/Status.js.map +1 -1
- package/dist/Authorization/index.js +26 -17
- package/dist/Authorization/index.js.map +1 -1
- package/package.json +1 -1
package/Authorization/Status.ts
CHANGED
|
@@ -11,13 +11,13 @@ export namespace Status {
|
|
|
11
11
|
error?: gracely.Error
|
|
12
12
|
}
|
|
13
13
|
export namespace Failed {
|
|
14
|
-
export function from(error
|
|
14
|
+
export function from(error?: gracely.Error): Failed {
|
|
15
15
|
let result: Status
|
|
16
|
-
if (error
|
|
16
|
+
if (error?.error?.includes("Card with id"))
|
|
17
17
|
result = { code: "14", reason: "Invalid card number" }
|
|
18
|
-
else if (error
|
|
18
|
+
else if (error?.error?.includes("must correspond to card limit")) {
|
|
19
19
|
result = { code: "13", reason: "Invalid amount" }
|
|
20
|
-
} else if (error
|
|
20
|
+
} else if (error?.error?.includes("Failed to reach account")) {
|
|
21
21
|
result = { code: "78", reason: "Invalid/nonexistent account specified (general)" }
|
|
22
22
|
} else if (gracely.client.InvalidContent.is(error) && error.content.description.includes("rules")) {
|
|
23
23
|
const reasons: string[] = error.content.details?.notes.reduce(
|
package/Authorization/index.ts
CHANGED
|
@@ -68,30 +68,39 @@ export namespace Authorization {
|
|
|
68
68
|
card: Card | gracely.Error,
|
|
69
69
|
transaction?: Transaction | gracely.Error
|
|
70
70
|
): Authorization {
|
|
71
|
-
|
|
72
|
-
id: Identifier.generate(),
|
|
73
|
-
...{ status: "approved" },
|
|
74
|
-
...(gracely.Error.is(card)
|
|
75
|
-
? { card: { id: creatable.card }, status: { ...Status.Failed.from(card), error: card } }
|
|
76
|
-
: {
|
|
77
|
-
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
78
|
-
account: card.account,
|
|
79
|
-
}),
|
|
71
|
+
const partial: Pick<Authorization, "created" | "amount" | "merchant" | "acquirer" | "reference" | "description"> = {
|
|
80
72
|
created: isoly.DateTime.now(),
|
|
81
73
|
amount: creatable.amount,
|
|
82
74
|
merchant: creatable.merchant,
|
|
83
75
|
acquirer: creatable.acquirer,
|
|
84
76
|
reference: creatable.reference,
|
|
85
77
|
description: creatable.description,
|
|
86
|
-
...(!transaction
|
|
87
|
-
? {}
|
|
88
|
-
: gracely.Error.is(transaction)
|
|
89
|
-
? { ...Status.Failed.from(transaction), error: transaction }
|
|
90
|
-
: {
|
|
91
|
-
id: transaction.id,
|
|
92
|
-
transaction: { id: transaction?.id, posted: transaction?.posted, description: transaction.description },
|
|
93
|
-
}),
|
|
94
78
|
}
|
|
79
|
+
let result: Authorization
|
|
80
|
+
if (gracely.Error.is(card))
|
|
81
|
+
result = {
|
|
82
|
+
id: Identifier.generate(),
|
|
83
|
+
status: Status.Failed.from(card),
|
|
84
|
+
...partial,
|
|
85
|
+
card: { id: creatable.card },
|
|
86
|
+
}
|
|
87
|
+
else if (gracely.Error.is(transaction) || !transaction)
|
|
88
|
+
result = {
|
|
89
|
+
id: Identifier.generate(),
|
|
90
|
+
status: Status.Failed.from(transaction),
|
|
91
|
+
...partial,
|
|
92
|
+
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
result = {
|
|
96
|
+
id: transaction.id,
|
|
97
|
+
status: "approved",
|
|
98
|
+
...partial,
|
|
99
|
+
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
100
|
+
account: card.account,
|
|
101
|
+
transaction: { id: transaction?.id, posted: transaction?.posted, description: transaction.description },
|
|
102
|
+
}
|
|
103
|
+
return result
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
export function toTransaction(authorization: Authorization, card: Card): Transaction.Creatable {
|
|
@@ -8,7 +8,7 @@ export declare namespace Status {
|
|
|
8
8
|
error?: gracely.Error;
|
|
9
9
|
}
|
|
10
10
|
namespace Failed {
|
|
11
|
-
function from(error
|
|
11
|
+
function from(error?: gracely.Error): Failed;
|
|
12
12
|
}
|
|
13
13
|
const type: isly.Type<"approved" | Failed>;
|
|
14
14
|
const is: isly.Type.IsFunction<"approved" | Failed>;
|
|
@@ -6,12 +6,12 @@ export var Status;
|
|
|
6
6
|
(function (Failed) {
|
|
7
7
|
function from(error) {
|
|
8
8
|
let result;
|
|
9
|
-
if (error
|
|
9
|
+
if (error?.error?.includes("Card with id"))
|
|
10
10
|
result = { code: "14", reason: "Invalid card number" };
|
|
11
|
-
else if (error
|
|
11
|
+
else if (error?.error?.includes("must correspond to card limit")) {
|
|
12
12
|
result = { code: "13", reason: "Invalid amount" };
|
|
13
13
|
}
|
|
14
|
-
else if (error
|
|
14
|
+
else if (error?.error?.includes("Failed to reach account")) {
|
|
15
15
|
result = { code: "78", reason: "Invalid/nonexistent account specified (general)" };
|
|
16
16
|
}
|
|
17
17
|
else if (gracely.client.InvalidContent.is(error) && error.content.description.includes("rules")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Status.js","sourceRoot":"../","sources":["Authorization/Status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,MAAM,KAAW,MAAM,CAwCtB;AAxCD,WAAiB,MAAM;IAMtB,IAAiB,MAAM,CAuBtB;IAvBD,WAAiB,MAAM;QACtB,SAAgB,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"../","sources":["Authorization/Status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,MAAM,KAAW,MAAM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,CAAA;QACd,CAAC;QArBe,WAAI,OAqBnB,CAAA;IACF,CAAC,EAvBgB,MAAM,GAAN,aAAM,KAAN,aAAM,QAuBtB;IACY,WAAI,GAAG,IAAI,CAAC,KAAK,CAC7B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EACvB,IAAI,CAAC,MAAM,CAAgB;QAC1B,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;QACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;QACxD,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;KAChE,CAAC,CACF,CAAA;IACY,SAAE,GAAG,OAAA,IAAI,CAAC,EAAE,CAAA;IACZ,WAAI,GAAG,OAAA,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC,EAxCgB,MAAM,KAAN,MAAM,QAwCtB"}
|
|
@@ -37,30 +37,39 @@ export var Authorization;
|
|
|
37
37
|
Authorization.is = Authorization.type.is;
|
|
38
38
|
Authorization.flaw = Authorization.type.flaw;
|
|
39
39
|
function fromCreatable(creatable, card, transaction) {
|
|
40
|
-
|
|
41
|
-
id: Identifier.generate(),
|
|
42
|
-
...{ status: "approved" },
|
|
43
|
-
...(gracely.Error.is(card)
|
|
44
|
-
? { card: { id: creatable.card }, status: { ...Status.Failed.from(card), error: card } }
|
|
45
|
-
: {
|
|
46
|
-
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
47
|
-
account: card.account,
|
|
48
|
-
}),
|
|
40
|
+
const partial = {
|
|
49
41
|
created: isoly.DateTime.now(),
|
|
50
42
|
amount: creatable.amount,
|
|
51
43
|
merchant: creatable.merchant,
|
|
52
44
|
acquirer: creatable.acquirer,
|
|
53
45
|
reference: creatable.reference,
|
|
54
46
|
description: creatable.description,
|
|
55
|
-
...(!transaction
|
|
56
|
-
? {}
|
|
57
|
-
: gracely.Error.is(transaction)
|
|
58
|
-
? { ...Status.Failed.from(transaction), error: transaction }
|
|
59
|
-
: {
|
|
60
|
-
id: transaction.id,
|
|
61
|
-
transaction: { id: transaction?.id, posted: transaction?.posted, description: transaction.description },
|
|
62
|
-
}),
|
|
63
47
|
};
|
|
48
|
+
let result;
|
|
49
|
+
if (gracely.Error.is(card))
|
|
50
|
+
result = {
|
|
51
|
+
id: Identifier.generate(),
|
|
52
|
+
status: Status.Failed.from(card),
|
|
53
|
+
...partial,
|
|
54
|
+
card: { id: creatable.card },
|
|
55
|
+
};
|
|
56
|
+
else if (gracely.Error.is(transaction) || !transaction)
|
|
57
|
+
result = {
|
|
58
|
+
id: Identifier.generate(),
|
|
59
|
+
status: Status.Failed.from(transaction),
|
|
60
|
+
...partial,
|
|
61
|
+
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
62
|
+
};
|
|
63
|
+
else
|
|
64
|
+
result = {
|
|
65
|
+
id: transaction.id,
|
|
66
|
+
status: "approved",
|
|
67
|
+
...partial,
|
|
68
|
+
card: { id: card.id, iin: card.details.iin, last4: card.details.last4, token: card.details.token },
|
|
69
|
+
account: card.account,
|
|
70
|
+
transaction: { id: transaction?.id, posted: transaction?.posted, description: transaction.description },
|
|
71
|
+
};
|
|
72
|
+
return result;
|
|
64
73
|
}
|
|
65
74
|
Authorization.fromCreatable = fromCreatable;
|
|
66
75
|
function toTransaction(authorization, card) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Authorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CA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