@pax2pay/model-banking 0.1.102 → 0.1.103

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.
@@ -0,0 +1,21 @@
1
+ import { isly } from "isly"
2
+ import { Transaction } from "../Transaction"
3
+ import { Base } from "./Base"
4
+ import { Creatable } from "./Creatable"
5
+
6
+ export interface Approved extends Base {
7
+ transaction: string
8
+ status: "approved"
9
+ }
10
+
11
+ export namespace Approved {
12
+ export const type = Base.type.extend<Approved>({
13
+ transaction: isly.string(),
14
+ status: isly.string("approved"),
15
+ })
16
+ export const is = type.is
17
+ export const flaw = type.flaw
18
+ export function fromCreatable(authorization: Creatable, transaction: Transaction): Approved {
19
+ return { ...Base.fromCreatable(authorization), transaction: transaction.id, status: "approved" }
20
+ }
21
+ }
@@ -0,0 +1,40 @@
1
+ import { cryptly } from "cryptly"
2
+ import { isoly } from "isoly"
3
+ import { isly } from "isly"
4
+ import { Acquirer } from "../Acquirer"
5
+ import { Merchant } from "../Merchant"
6
+ import { Creatable } from "./Creatable"
7
+
8
+ export type Base = {
9
+ id: cryptly.Identifier
10
+ card: string
11
+ created: isoly.DateTime
12
+ amount: [isoly.Currency, number]
13
+ merchant: Merchant
14
+ acquirer: Acquirer
15
+ description: string
16
+ }
17
+ export namespace Base {
18
+ export function fromCreatable(authorization: Creatable): Base {
19
+ return {
20
+ id: cryptly.Identifier.generate(8),
21
+ card: authorization.card,
22
+ created: isoly.DateTime.now(),
23
+ amount: authorization.amount,
24
+ merchant: authorization.merchant,
25
+ acquirer: authorization.acquirer,
26
+ description: authorization.description,
27
+ }
28
+ }
29
+ export const type = isly.object<Base>({
30
+ id: isly.fromIs("Authorization.id", cryptly.Identifier.is),
31
+ card: isly.string(),
32
+ created: isly.fromIs("Authorization.created", isoly.DateTime.is),
33
+ amount: isly.tuple(isly.fromIs("isoly.Currency", isoly.Currency.is), isly.number()),
34
+ merchant: Merchant.type,
35
+ acquirer: Acquirer.type,
36
+ description: isly.string(),
37
+ })
38
+ export const is = type.is
39
+ export const flaw = type.flaw
40
+ }
@@ -0,0 +1,44 @@
1
+ import { gracely } from "gracely"
2
+ import { isly } from "isly"
3
+ import { Transaction } from "../Transaction"
4
+ import { Base } from "./Base"
5
+ import { Creatable } from "./Creatable"
6
+
7
+ export interface Failed extends Base {
8
+ status: { code: string; reason: string | string[] }
9
+ }
10
+
11
+ export namespace Failed {
12
+ export const type = Base.type.extend<Failed>({
13
+ status: isly.object({ code: isly.string(), reason: isly.union(isly.string(), isly.string().array()) }),
14
+ })
15
+ export const is = type.is
16
+ export const flaw = type.flaw
17
+ export function fromCreatable(authorization: Creatable, transaction: gracely.Error): Failed {
18
+ return { ...Base.fromCreatable(authorization), ...statusFrom(transaction) }
19
+ }
20
+ export function statusFrom(transaction: gracely.Error): Pick<Failed, "status"> {
21
+ let result: Pick<Failed, "status">
22
+ if (transaction.error?.includes("Card with id"))
23
+ result = { status: { code: "14", reason: "Invalid card number" } }
24
+ else if (transaction.error?.includes("must correspond to card limit")) {
25
+ result = { status: { code: "13", reason: "Invalid amount" } }
26
+ } else if (transaction.error?.includes("Failed to reach account")) {
27
+ result = { status: { code: "78", reason: "Invalid/nonexistent account specified (general)" } }
28
+ } else if (gracely.client.InvalidContent.is(transaction) && transaction.content.description.includes("rules")) {
29
+ const reasons: string[] = transaction.content.details?.notes.reduce(
30
+ (a: string[], c: Transaction.Note) => [...a, `${c.created} ${c.author}: ${c.text ?? ""}`],
31
+ []
32
+ )
33
+ result = {
34
+ status: {
35
+ code: "62", //Restricted card: "This means that the card that you processed is restricted to where it can be used.
36
+ //The restricted card is only allowed to be used for certain types of businesses or purchases."
37
+ reason: ["Restricted card.", ...reasons],
38
+ },
39
+ }
40
+ } else
41
+ result = { status: { code: "05", reason: "Do not honor" } } //default
42
+ return result
43
+ }
44
+ }
@@ -1,54 +1,31 @@
1
- import { cryptly } from "cryptly"
2
- import { isoly } from "isoly"
1
+ import { gracely } from "gracely"
3
2
  import { isly } from "isly"
4
- import { Acquirer } from "../Acquirer"
5
3
  import { Card } from "../Card"
6
- import { Merchant } from "../Merchant"
7
4
  import { Transaction } from "../Transaction"
5
+ import { Approved as AuthorizationApproved } from "./Approved"
8
6
  import { Creatable as AuthorizationCreatable } from "./Creatable"
7
+ import { Failed as AuthorizationFailed } from "./Failed"
9
8
 
10
- export interface Authorization {
11
- id: cryptly.Identifier
12
- card: string
13
- created: isoly.DateTime
14
- amount: [isoly.Currency, number]
15
- merchant: Merchant
16
- acquirer: Acquirer
17
- description: string
18
- transaction?: string
19
- status?: "approved" | { code: string; reason: string | string[] }
20
- }
9
+ export type Authorization = Authorization.Failed | Authorization.Approved
21
10
  export namespace Authorization {
22
- export function fromCreatable(authorization: Authorization.Creatable): Authorization {
23
- return {
24
- id: cryptly.Identifier.generate(8),
25
- card: authorization.card,
26
- created: isoly.DateTime.now(),
27
- amount: authorization.amount,
28
- merchant: authorization.merchant,
29
- acquirer: authorization.acquirer,
30
- description: authorization.description,
31
- }
11
+ export type Approved = AuthorizationApproved
12
+ export const Approved = AuthorizationApproved
13
+ export type Failed = AuthorizationFailed
14
+ export const Failed = AuthorizationFailed
15
+ export type Creatable = AuthorizationCreatable
16
+ export const Creatable = AuthorizationCreatable
17
+ export function fromCreatable(
18
+ authorization: Authorization.Creatable,
19
+ transaction: Transaction | gracely.Error
20
+ ): Authorization {
21
+ return gracely.Error.is(transaction)
22
+ ? Authorization.Failed.fromCreatable(authorization, transaction)
23
+ : Authorization.Approved.fromCreatable(authorization, transaction)
32
24
  }
33
- export const type = isly.object<Authorization>({
34
- id: isly.fromIs("Authorization.id", cryptly.Identifier.is),
35
- card: isly.string(),
36
- created: isly.fromIs("Authorization.created", isoly.DateTime.is),
37
- amount: isly.tuple(isly.fromIs("isoly.Currency", isoly.Currency.is), isly.number()),
38
- merchant: Merchant.type,
39
- acquirer: Acquirer.type,
40
- description: isly.string(),
41
- transaction: isly.string().optional(),
42
- status: isly
43
- .union(
44
- isly.string("approved"),
45
- isly.object<{ code: string; reason: string }>({
46
- code: isly.string(),
47
- reason: isly.union(isly.string(), isly.string().array()),
48
- })
49
- )
50
- .optional(),
51
- })
25
+ export const type = isly.union<Authorization, Authorization.Failed, Authorization.Approved>(
26
+ Authorization.Failed.type,
27
+ Authorization.Approved.type
28
+ )
52
29
  export const is = type.is
53
30
  export const flaw = type.flaw
54
31
 
@@ -68,6 +45,4 @@ export namespace Authorization {
68
45
  },
69
46
  }
70
47
  }
71
- export type Creatable = AuthorizationCreatable
72
- export const Creatable = AuthorizationCreatable
73
48
  }
@@ -0,0 +1,14 @@
1
+ import { isly } from "isly";
2
+ import { Transaction } from "../Transaction";
3
+ import { Base } from "./Base";
4
+ import { Creatable } from "./Creatable";
5
+ export interface Approved extends Base {
6
+ transaction: string;
7
+ status: "approved";
8
+ }
9
+ export declare namespace Approved {
10
+ const type: isly.object.ExtendableType<Approved>;
11
+ const is: isly.Type.IsFunction<Approved>;
12
+ const flaw: isly.Type.FlawFunction;
13
+ function fromCreatable(authorization: Creatable, transaction: Transaction): Approved;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { isly } from "isly";
2
+ import { Base } from "./Base";
3
+ export var Approved;
4
+ (function (Approved) {
5
+ Approved.type = Base.type.extend({
6
+ transaction: isly.string(),
7
+ status: isly.string("approved"),
8
+ });
9
+ Approved.is = Approved.type.is;
10
+ Approved.flaw = Approved.type.flaw;
11
+ function fromCreatable(authorization, transaction) {
12
+ return { ...Base.fromCreatable(authorization), transaction: transaction.id, status: "approved" };
13
+ }
14
+ Approved.fromCreatable = fromCreatable;
15
+ })(Approved || (Approved = {}));
16
+ //# sourceMappingURL=Approved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Approved.js","sourceRoot":"../","sources":["Authorization/Approved.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAQ7B,MAAM,KAAW,QAAQ,CAUxB;AAVD,WAAiB,QAAQ;IACX,aAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAW;QAC9C,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;QAC1B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;KAC/B,CAAC,CAAA;IACW,WAAE,GAAG,SAAA,IAAI,CAAC,EAAE,CAAA;IACZ,aAAI,GAAG,SAAA,IAAI,CAAC,IAAI,CAAA;IAC7B,SAAgB,aAAa,CAAC,aAAwB,EAAE,WAAwB;QAC/E,OAAO,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;IACjG,CAAC;IAFe,sBAAa,gBAE5B,CAAA;AACF,CAAC,EAVgB,QAAQ,KAAR,QAAQ,QAUxB"}
@@ -0,0 +1,21 @@
1
+ import { cryptly } from "cryptly";
2
+ import { isoly } from "isoly";
3
+ import { isly } from "isly";
4
+ import { Acquirer } from "../Acquirer";
5
+ import { Merchant } from "../Merchant";
6
+ import { Creatable } from "./Creatable";
7
+ export type Base = {
8
+ id: cryptly.Identifier;
9
+ card: string;
10
+ created: isoly.DateTime;
11
+ amount: [isoly.Currency, number];
12
+ merchant: Merchant;
13
+ acquirer: Acquirer;
14
+ description: string;
15
+ };
16
+ export declare namespace Base {
17
+ function fromCreatable(authorization: Creatable): Base;
18
+ const type: isly.object.ExtendableType<Base>;
19
+ const is: isly.Type.IsFunction<Base>;
20
+ const flaw: isly.Type.FlawFunction;
21
+ }
@@ -0,0 +1,32 @@
1
+ import { cryptly } from "cryptly";
2
+ import { isoly } from "isoly";
3
+ import { isly } from "isly";
4
+ import { Acquirer } from "../Acquirer";
5
+ import { Merchant } from "../Merchant";
6
+ export var Base;
7
+ (function (Base) {
8
+ function fromCreatable(authorization) {
9
+ return {
10
+ id: cryptly.Identifier.generate(8),
11
+ card: authorization.card,
12
+ created: isoly.DateTime.now(),
13
+ amount: authorization.amount,
14
+ merchant: authorization.merchant,
15
+ acquirer: authorization.acquirer,
16
+ description: authorization.description,
17
+ };
18
+ }
19
+ Base.fromCreatable = fromCreatable;
20
+ Base.type = isly.object({
21
+ id: isly.fromIs("Authorization.id", cryptly.Identifier.is),
22
+ card: isly.string(),
23
+ created: isly.fromIs("Authorization.created", isoly.DateTime.is),
24
+ amount: isly.tuple(isly.fromIs("isoly.Currency", isoly.Currency.is), isly.number()),
25
+ merchant: Merchant.type,
26
+ acquirer: Acquirer.type,
27
+ description: isly.string(),
28
+ });
29
+ Base.is = Base.type.is;
30
+ Base.flaw = Base.type.flaw;
31
+ })(Base || (Base = {}));
32
+ //# sourceMappingURL=Base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.js","sourceRoot":"../","sources":["Authorization/Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAYtC,MAAM,KAAW,IAAI,CAuBpB;AAvBD,WAAiB,IAAI;IACpB,SAAgB,aAAa,CAAC,aAAwB;QACrD,OAAO;YACN,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClC,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC7B,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,WAAW,EAAE,aAAa,CAAC,WAAW;SACtC,CAAA;IACF,CAAC;IAVe,kBAAa,gBAU5B,CAAA;IACY,SAAI,GAAG,IAAI,CAAC,MAAM,CAAO;QACrC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1D,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACnF,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;KAC1B,CAAC,CAAA;IACW,OAAE,GAAG,KAAA,IAAI,CAAC,EAAE,CAAA;IACZ,SAAI,GAAG,KAAA,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC,EAvBgB,IAAI,KAAJ,IAAI,QAuBpB"}
@@ -0,0 +1,17 @@
1
+ import { gracely } from "gracely";
2
+ import { isly } from "isly";
3
+ import { Base } from "./Base";
4
+ import { Creatable } from "./Creatable";
5
+ export interface Failed extends Base {
6
+ status: {
7
+ code: string;
8
+ reason: string | string[];
9
+ };
10
+ }
11
+ export declare namespace Failed {
12
+ const type: isly.object.ExtendableType<Failed>;
13
+ const is: isly.Type.IsFunction<Failed>;
14
+ const flaw: isly.Type.FlawFunction;
15
+ function fromCreatable(authorization: Creatable, transaction: gracely.Error): Failed;
16
+ function statusFrom(transaction: gracely.Error): Pick<Failed, "status">;
17
+ }
@@ -0,0 +1,40 @@
1
+ import { gracely } from "gracely";
2
+ import { isly } from "isly";
3
+ import { Base } from "./Base";
4
+ export var Failed;
5
+ (function (Failed) {
6
+ Failed.type = Base.type.extend({
7
+ status: isly.object({ code: isly.string(), reason: isly.union(isly.string(), isly.string().array()) }),
8
+ });
9
+ Failed.is = Failed.type.is;
10
+ Failed.flaw = Failed.type.flaw;
11
+ function fromCreatable(authorization, transaction) {
12
+ return { ...Base.fromCreatable(authorization), ...statusFrom(transaction) };
13
+ }
14
+ Failed.fromCreatable = fromCreatable;
15
+ function statusFrom(transaction) {
16
+ let result;
17
+ if (transaction.error?.includes("Card with id"))
18
+ result = { status: { code: "14", reason: "Invalid card number" } };
19
+ else if (transaction.error?.includes("must correspond to card limit")) {
20
+ result = { status: { code: "13", reason: "Invalid amount" } };
21
+ }
22
+ else if (transaction.error?.includes("Failed to reach account")) {
23
+ result = { status: { code: "78", reason: "Invalid/nonexistent account specified (general)" } };
24
+ }
25
+ else if (gracely.client.InvalidContent.is(transaction) && transaction.content.description.includes("rules")) {
26
+ const reasons = transaction.content.details?.notes.reduce((a, c) => [...a, `${c.created} ${c.author}: ${c.text ?? ""}`], []);
27
+ result = {
28
+ status: {
29
+ code: "62",
30
+ reason: ["Restricted card.", ...reasons],
31
+ },
32
+ };
33
+ }
34
+ else
35
+ result = { status: { code: "05", reason: "Do not honor" } };
36
+ return result;
37
+ }
38
+ Failed.statusFrom = statusFrom;
39
+ })(Failed || (Failed = {}));
40
+ //# sourceMappingURL=Failed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Failed.js","sourceRoot":"../","sources":["Authorization/Failed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAO7B,MAAM,KAAW,MAAM,CAiCtB;AAjCD,WAAiB,MAAM;IACT,WAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAS;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC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CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAClE,CAAC,CAAW,EAAE,CAAmB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,EACzF,EAAE,CACF,CAAA;YACD,MAAM,GAAG;gBACR,MAAM,EAAE;oBACP,IAAI,EAAE,IAAI;oBAEV,MAAM,EAAE,CAAC,kBAAkB,EAAE,GAAG,OAAO,CAAC;iBACxC;aACD,CAAA;SACD;;YACA,MAAM,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,CAAA;QAC5D,OAAO,MAAM,CAAA;IACd,CAAC;IAvBe,iBAAU,aAuBzB,CAAA;AACF,CAAC,EAjCgB,MAAM,KAAN,MAAM,QAiCtB"}
@@ -1,31 +1,21 @@
1
- import { cryptly } from "cryptly";
2
- import { isoly } from "isoly";
1
+ import { gracely } from "gracely";
3
2
  import { isly } from "isly";
4
- import { Acquirer } from "../Acquirer";
5
3
  import { Card } from "../Card";
6
- import { Merchant } from "../Merchant";
7
4
  import { Transaction } from "../Transaction";
5
+ import { Approved as AuthorizationApproved } from "./Approved";
8
6
  import { Creatable as AuthorizationCreatable } from "./Creatable";
9
- export interface Authorization {
10
- id: cryptly.Identifier;
11
- card: string;
12
- created: isoly.DateTime;
13
- amount: [isoly.Currency, number];
14
- merchant: Merchant;
15
- acquirer: Acquirer;
16
- description: string;
17
- transaction?: string;
18
- status?: "approved" | {
19
- code: string;
20
- reason: string | string[];
21
- };
22
- }
7
+ import { Failed as AuthorizationFailed } from "./Failed";
8
+ export type Authorization = Authorization.Failed | Authorization.Approved;
23
9
  export declare namespace Authorization {
24
- function fromCreatable(authorization: Authorization.Creatable): Authorization;
25
- const type: isly.object.ExtendableType<Authorization>;
10
+ type Approved = AuthorizationApproved;
11
+ const Approved: typeof AuthorizationApproved;
12
+ type Failed = AuthorizationFailed;
13
+ const Failed: typeof AuthorizationFailed;
14
+ type Creatable = AuthorizationCreatable;
15
+ const Creatable: typeof AuthorizationCreatable;
16
+ function fromCreatable(authorization: Authorization.Creatable, transaction: Transaction | gracely.Error): Authorization;
17
+ const type: isly.Type<Authorization>;
26
18
  const is: isly.Type.IsFunction<Authorization>;
27
19
  const flaw: isly.Type.FlawFunction;
28
20
  function toTransaction(authorization: Authorization, card: Card): Transaction.Creatable;
29
- type Creatable = AuthorizationCreatable;
30
- const Creatable: typeof AuthorizationCreatable;
31
21
  }
@@ -1,39 +1,20 @@
1
- import { cryptly } from "cryptly";
2
- import { isoly } from "isoly";
1
+ import { gracely } from "gracely";
3
2
  import { isly } from "isly";
4
- import { Acquirer } from "../Acquirer";
5
- import { Merchant } from "../Merchant";
3
+ import { Approved as AuthorizationApproved } from "./Approved";
6
4
  import { Creatable as AuthorizationCreatable } from "./Creatable";
5
+ import { Failed as AuthorizationFailed } from "./Failed";
7
6
  export var Authorization;
8
7
  (function (Authorization) {
9
- function fromCreatable(authorization) {
10
- return {
11
- id: cryptly.Identifier.generate(8),
12
- card: authorization.card,
13
- created: isoly.DateTime.now(),
14
- amount: authorization.amount,
15
- merchant: authorization.merchant,
16
- acquirer: authorization.acquirer,
17
- description: authorization.description,
18
- };
8
+ Authorization.Approved = AuthorizationApproved;
9
+ Authorization.Failed = AuthorizationFailed;
10
+ Authorization.Creatable = AuthorizationCreatable;
11
+ function fromCreatable(authorization, transaction) {
12
+ return gracely.Error.is(transaction)
13
+ ? Authorization.Failed.fromCreatable(authorization, transaction)
14
+ : Authorization.Approved.fromCreatable(authorization, transaction);
19
15
  }
20
16
  Authorization.fromCreatable = fromCreatable;
21
- Authorization.type = isly.object({
22
- id: isly.fromIs("Authorization.id", cryptly.Identifier.is),
23
- card: isly.string(),
24
- created: isly.fromIs("Authorization.created", isoly.DateTime.is),
25
- amount: isly.tuple(isly.fromIs("isoly.Currency", isoly.Currency.is), isly.number()),
26
- merchant: Merchant.type,
27
- acquirer: Acquirer.type,
28
- description: isly.string(),
29
- transaction: isly.string().optional(),
30
- status: isly
31
- .union(isly.string("approved"), isly.object({
32
- code: isly.string(),
33
- reason: isly.union(isly.string(), isly.string().array()),
34
- }))
35
- .optional(),
36
- });
17
+ Authorization.type = isly.union(Authorization.Failed.type, Authorization.Approved.type);
37
18
  Authorization.is = Authorization.type.is;
38
19
  Authorization.flaw = Authorization.type.flaw;
39
20
  function toTransaction(authorization, card) {
@@ -53,6 +34,5 @@ export var Authorization;
53
34
  };
54
35
  }
55
36
  Authorization.toTransaction = toTransaction;
56
- Authorization.Creatable = AuthorizationCreatable;
57
37
  })(Authorization || (Authorization = {}));
58
38
  //# sourceMappingURL=index.js.map
@@ -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,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,SAAS,IAAI,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAajE,MAAM,KAAW,aAAa,CAoD7B;AApDD,WAAiB,aAAa;IAC7B,SAAgB,aAAa,CAAC,aAAsC;QACnE,OAAO;YACN,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClC,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC7B,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,QAAQ,EAAE,aAAa,CAAC,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,EAAE,WAAW,CAAC;YAChE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;IACpE,CAAC;IAPe,2BAAa,gBAO5B,CAAA;IACY,kBAAI,GAAG,IAAI,CAAC,KAAK,CAC7B,aAAa,CAAC,MAAM,CAAC,IAAI,EACzB,aAAa,CAAC,QAAQ,CAAC,IAAI,CAC3B,CAAA;IACY,gBAAE,GAAG,cAAA,IAAI,CAAC,EAAE,CAAA;IACZ,kBAAI,GAAG,cAAA,IAAI,CAAC,IAAI,CAAA;IAE7B,SAAgB,aAAa,CAAC,aAA4B,EAAE,IAAU;QACrE,OAAO;YACN,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/B,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YACjC,WAAW,EAAE,aAAa,CAAC,WAAW;YACtC,WAAW,EAAE;gBACZ,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;gBACrB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;gBAC3B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;gBAC3B,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,QAAQ,EAAE,aAAa,CAAC,QAAQ;aAChC;SACD,CAAA;IACF,CAAC;IAfe,2BAAa,gBAe5B,CAAA;AACF,CAAC,EAtCgB,aAAa,KAAb,aAAa,QAsC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.102",
3
+ "version": "0.1.103",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",