@pax2pay/model-banking 0.1.455 → 0.1.456
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/Card/Operation/index.ts +12 -4
- package/Operation/Changes.ts +1 -1
- package/Operation/Creatable.ts +1 -1
- package/Settlement/Entry/{Legacy/Cancel.ts → Cancel.ts} +5 -5
- package/Settlement/Entry/{Legacy/Capture.ts → Capture.ts} +5 -5
- package/Settlement/Entry/Creatable.ts +11 -111
- package/Settlement/Entry/{Legacy/Refund.ts → Refund.ts} +8 -8
- package/Settlement/Entry/{Legacy/Unknown.ts → Unknown.ts} +3 -3
- package/Settlement/Entry/index.ts +50 -19
- package/Settlement/index.ts +1 -1
- package/Transaction/Incoming.ts +1 -1
- package/Transaction/index.ts +1 -1
- package/Warning/Settlement/UnknownEntry.ts +3 -6
- package/dist/Card/Operation/index.d.ts +2 -1
- package/dist/Card/Operation/index.js +12 -3
- package/dist/Card/Operation/index.js.map +1 -1
- package/dist/Operation/Changes.d.ts +1 -1
- package/dist/Operation/Creatable.d.ts +1 -1
- package/dist/Settlement/Entry/{Legacy/Cancel.d.ts → Cancel.d.ts} +5 -5
- package/dist/Settlement/Entry/{Legacy/Cancel.js → Cancel.js} +5 -5
- package/dist/Settlement/Entry/Cancel.js.map +1 -0
- package/dist/Settlement/Entry/{Legacy/Capture.d.ts → Capture.d.ts} +5 -5
- package/dist/Settlement/Entry/{Legacy/Capture.js → Capture.js} +5 -5
- package/dist/Settlement/Entry/Capture.js.map +1 -0
- package/dist/Settlement/Entry/Creatable.d.ts +6 -51
- package/dist/Settlement/Entry/Creatable.js +5 -88
- package/dist/Settlement/Entry/Creatable.js.map +1 -1
- package/dist/Settlement/Entry/{Legacy/Refund.d.ts → Refund.d.ts} +8 -8
- package/dist/Settlement/Entry/{Legacy/Refund.js → Refund.js} +7 -7
- package/dist/Settlement/Entry/Refund.js.map +1 -0
- package/dist/Settlement/Entry/{Legacy/Unknown.d.ts → Unknown.d.ts} +3 -3
- package/dist/Settlement/Entry/{Legacy/Unknown.js → Unknown.js} +3 -3
- package/dist/Settlement/Entry/Unknown.js.map +1 -0
- package/dist/Settlement/Entry/index.d.ts +16 -19
- package/dist/Settlement/Entry/index.js +45 -13
- package/dist/Settlement/Entry/index.js.map +1 -1
- package/dist/Settlement/index.d.ts +1 -1
- package/dist/Settlement/index.js.map +1 -1
- package/dist/Transaction/Incoming.d.ts +1 -1
- package/dist/Transaction/index.d.ts +1 -1
- package/dist/Warning/Settlement/UnknownEntry.d.ts +2 -6
- package/dist/Warning/Settlement/UnknownEntry.js +1 -2
- package/dist/Warning/Settlement/UnknownEntry.js.map +1 -1
- package/package.json +1 -1
- package/Settlement/Entry/Failed.ts +0 -27
- package/Settlement/Entry/Legacy/Creatable.ts +0 -15
- package/Settlement/Entry/Legacy/index.ts +0 -55
- package/Settlement/Entry/Succeeded.ts +0 -22
- package/Settlement/Entry/fromCreatable.ts +0 -38
- package/Settlement/Entry/fromLegacy.ts +0 -86
- package/Settlement/Entry/type.ts +0 -6
- package/dist/Settlement/Entry/Failed.d.ts +0 -11
- package/dist/Settlement/Entry/Failed.js +0 -12
- package/dist/Settlement/Entry/Failed.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/Cancel.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/Capture.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/Creatable.d.ts +0 -9
- package/dist/Settlement/Entry/Legacy/Creatable.js +0 -10
- package/dist/Settlement/Entry/Legacy/Creatable.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/Refund.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/Unknown.js.map +0 -1
- package/dist/Settlement/Entry/Legacy/index.d.ts +0 -19
- package/dist/Settlement/Entry/Legacy/index.js +0 -50
- package/dist/Settlement/Entry/Legacy/index.js.map +0 -1
- package/dist/Settlement/Entry/Succeeded.d.ts +0 -14
- package/dist/Settlement/Entry/Succeeded.js +0 -17
- package/dist/Settlement/Entry/Succeeded.js.map +0 -1
- package/dist/Settlement/Entry/fromCreatable.d.ts +0 -6
- package/dist/Settlement/Entry/fromCreatable.js +0 -30
- package/dist/Settlement/Entry/fromCreatable.js.map +0 -1
- package/dist/Settlement/Entry/fromLegacy.d.ts +0 -3
- package/dist/Settlement/Entry/fromLegacy.js +0 -78
- package/dist/Settlement/Entry/fromLegacy.js.map +0 -1
- package/dist/Settlement/Entry/type.d.ts +0 -3
- package/dist/Settlement/Entry/type.js +0 -5
- package/dist/Settlement/Entry/type.js.map +0 -1
package/Card/Operation/index.ts
CHANGED
|
@@ -16,15 +16,23 @@ export namespace Operation {
|
|
|
16
16
|
created: isoly.DateTime.now(),
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
export function fromEntry(entry: Entry
|
|
20
|
-
return entry.
|
|
19
|
+
export function fromEntry(entry: Entry): Operation | undefined {
|
|
20
|
+
return entry.type == "unknown"
|
|
21
21
|
? undefined
|
|
22
22
|
: {
|
|
23
23
|
type: "authorization",
|
|
24
|
-
id: entry.transaction ?? "unknown",
|
|
25
|
-
status: entry.type
|
|
24
|
+
id: (entry.type != "refund" ? entry.authorization?.id : entry.transaction?.id) ?? "unknown",
|
|
25
|
+
status: Operation.fromEntryStatus(entry.type),
|
|
26
26
|
created: isoly.DateTime.now(),
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export function fromEntryStatus(status: Exclude<Entry.Type, "unknown">): OperationAuthorization.Status {
|
|
30
|
+
const statusConverter: Record<Exclude<Entry.Type, "unknown">, OperationAuthorization.Status> = {
|
|
31
|
+
capture: "captured",
|
|
32
|
+
cancel: "cancelled",
|
|
33
|
+
refund: "refunded",
|
|
34
|
+
}
|
|
35
|
+
return statusConverter[status]
|
|
36
|
+
}
|
|
29
37
|
export const type = isly.union(Card.type, OperationAuthorization.type)
|
|
30
38
|
}
|
package/Operation/Changes.ts
CHANGED
|
@@ -114,7 +114,7 @@ export namespace Changes {
|
|
|
114
114
|
}
|
|
115
115
|
export function fromRefund(
|
|
116
116
|
settlement: string | undefined, // FIXME: remove | undefined when we're sure we send the id
|
|
117
|
-
refund: Settlement.Entry.Creatable
|
|
117
|
+
refund: Settlement.Entry.Refund.Creatable,
|
|
118
118
|
charge: number | undefined,
|
|
119
119
|
sum: Sum
|
|
120
120
|
): Changes {
|
package/Operation/Creatable.ts
CHANGED
|
@@ -36,7 +36,7 @@ export namespace Creatable {
|
|
|
36
36
|
changes: Changes.type,
|
|
37
37
|
type: isly.string(types),
|
|
38
38
|
})
|
|
39
|
-
export function fromRefund(account: string, settlement: string, entry: Settlement.Entry.Creatable
|
|
39
|
+
export function fromRefund(account: string, settlement: string, entry: Settlement.Entry.Refund.Creatable): Creatable {
|
|
40
40
|
// The Entry.Refund.Creatable has negative amount and fee
|
|
41
41
|
// The operation amounts should always be positive
|
|
42
42
|
const [currency, entryAmount] = entry.amount
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import { Amount } from "
|
|
4
|
-
import { Authorization } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Amount } from "../../Amount"
|
|
4
|
+
import { Authorization } from "../../Authorization"
|
|
5
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier"
|
|
6
|
+
import { Batch } from "../Batch"
|
|
7
|
+
import { Fee } from "../Fee"
|
|
8
8
|
|
|
9
9
|
export interface Cancel extends Omit<Cancel.Creatable, "settlement"> {
|
|
10
10
|
status: "succeeded" | "failed"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import { Amount } from "
|
|
4
|
-
import { Authorization } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Amount } from "../../Amount"
|
|
4
|
+
import { Authorization } from "../../Authorization"
|
|
5
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier"
|
|
6
|
+
import { Batch } from "../Batch"
|
|
7
|
+
import { Fee } from "../Fee"
|
|
8
8
|
|
|
9
9
|
export interface Capture extends Omit<Capture.Creatable, "settlement"> {
|
|
10
10
|
status: "succeeded" | "failed"
|
|
@@ -1,115 +1,15 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Fee } from "../Fee"
|
|
7
|
-
import { Identifier as SettlementIdentifier } from "../Identifier"
|
|
8
|
-
import { Entry as LegacyEntry } from "./Legacy"
|
|
2
|
+
import { Cancel as EntryCancel } from "./Cancel"
|
|
3
|
+
import { Capture as EntryCapture } from "./Capture"
|
|
4
|
+
import { Refund as EntryRefund } from "./Refund"
|
|
5
|
+
import { Unknown as EntryUnknown } from "./Unknown"
|
|
9
6
|
|
|
10
|
-
export type Creatable = Creatable.
|
|
7
|
+
export type Creatable = EntryCancel.Creatable | EntryCapture.Creatable | EntryRefund.Creatable | EntryUnknown.Creatable
|
|
11
8
|
export namespace Creatable {
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
acquirer: Acquirer
|
|
19
|
-
reference: string
|
|
20
|
-
batch: Batch
|
|
21
|
-
fee: Fee
|
|
22
|
-
amount: Amount
|
|
23
|
-
settlement: SettlementIdentifier
|
|
24
|
-
}
|
|
25
|
-
export namespace Base {
|
|
26
|
-
export const type = isly.object<Base>({
|
|
27
|
-
card: isly.string(),
|
|
28
|
-
transaction: isly.string().optional(),
|
|
29
|
-
account: isly.string(),
|
|
30
|
-
approvalCode: isly.string(),
|
|
31
|
-
merchant: Merchant.type,
|
|
32
|
-
acquirer: Acquirer.type,
|
|
33
|
-
reference: isly.string(),
|
|
34
|
-
batch: Batch.type,
|
|
35
|
-
fee: Fee.type,
|
|
36
|
-
amount: Amount.type,
|
|
37
|
-
settlement: SettlementIdentifier.type,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
export interface Capture extends Base {
|
|
41
|
-
type: "capture"
|
|
42
|
-
}
|
|
43
|
-
export namespace Capture {
|
|
44
|
-
export const type = Base.type.extend<Capture>({
|
|
45
|
-
type: isly.string("capture"),
|
|
46
|
-
})
|
|
47
|
-
export function fromLegacy(maybeLegacy: Capture | LegacyEntry.Capture.Creatable): Capture {
|
|
48
|
-
return type.is(maybeLegacy)
|
|
49
|
-
? maybeLegacy
|
|
50
|
-
: {
|
|
51
|
-
type: maybeLegacy.type,
|
|
52
|
-
card: maybeLegacy.authorization.card.id,
|
|
53
|
-
transaction: maybeLegacy.authorization.transaction?.id,
|
|
54
|
-
account: maybeLegacy.authorization.account || "unknown",
|
|
55
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
56
|
-
merchant: maybeLegacy.authorization.merchant,
|
|
57
|
-
acquirer: maybeLegacy.authorization.acquirer,
|
|
58
|
-
reference: maybeLegacy.reference,
|
|
59
|
-
batch: maybeLegacy.batch,
|
|
60
|
-
fee: maybeLegacy.fee,
|
|
61
|
-
amount: maybeLegacy.amount,
|
|
62
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export interface Refund extends Base {
|
|
67
|
-
type: "refund"
|
|
68
|
-
}
|
|
69
|
-
export namespace Refund {
|
|
70
|
-
export const type = Base.type.extend<Refund>({
|
|
71
|
-
type: isly.string("refund"),
|
|
72
|
-
})
|
|
73
|
-
export function fromLegacy(maybeLegacy: Refund | LegacyEntry.Refund.Creatable): Refund {
|
|
74
|
-
return type.is(maybeLegacy)
|
|
75
|
-
? maybeLegacy
|
|
76
|
-
: {
|
|
77
|
-
type: maybeLegacy.type,
|
|
78
|
-
card: maybeLegacy.card,
|
|
79
|
-
account: maybeLegacy.account ?? "unknown",
|
|
80
|
-
approvalCode: maybeLegacy.authorization.approvalCode ?? "unknown",
|
|
81
|
-
merchant: maybeLegacy.merchant,
|
|
82
|
-
acquirer: maybeLegacy.acquirer,
|
|
83
|
-
reference: maybeLegacy.reference,
|
|
84
|
-
batch: maybeLegacy.batch,
|
|
85
|
-
fee: maybeLegacy.fee,
|
|
86
|
-
amount: maybeLegacy.amount,
|
|
87
|
-
settlement: maybeLegacy.settlement ?? "unknown",
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export type Known = Capture | Refund
|
|
92
|
-
|
|
93
|
-
export namespace Known {
|
|
94
|
-
export const type = isly.union(Capture.type, Refund.type)
|
|
95
|
-
export function fromLegacy(
|
|
96
|
-
maybeLegacy: Creatable.Known | LegacyEntry.Capture.Creatable | LegacyEntry.Refund.Creatable
|
|
97
|
-
): Creatable.Known {
|
|
98
|
-
return maybeLegacy.type == "capture" ? Capture.fromLegacy(maybeLegacy) : Refund.fromLegacy(maybeLegacy)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export interface Unknown extends Partial<Base> {
|
|
102
|
-
type: "unknown"
|
|
103
|
-
data: Record<string, unknown>
|
|
104
|
-
}
|
|
105
|
-
export namespace Unknown {
|
|
106
|
-
export const type = isly.object<Unknown>({
|
|
107
|
-
...(Object.fromEntries(
|
|
108
|
-
Object.entries(Base.type.getProperties()).map(([k, v]) => [k, v.optional()])
|
|
109
|
-
) as isly.object.Properties<Partial<Base>>), // TODO: Add "Partial" to isly
|
|
110
|
-
type: isly.string("unknown"),
|
|
111
|
-
data: isly.record<Record<string, unknown>>(isly.string(), isly.any()),
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
export const type = isly.union(Known.type, Unknown.type)
|
|
9
|
+
export const type = isly.union(
|
|
10
|
+
EntryCancel.Creatable.type,
|
|
11
|
+
EntryCapture.Creatable.type,
|
|
12
|
+
EntryRefund.Creatable.type,
|
|
13
|
+
EntryUnknown.Creatable.type
|
|
14
|
+
)
|
|
115
15
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import { Acquirer } from "
|
|
4
|
-
import { Amount } from "
|
|
5
|
-
import { Authorization } from "
|
|
6
|
-
import { Merchant } from "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { Acquirer } from "../../Acquirer"
|
|
4
|
+
import { Amount } from "../../Amount"
|
|
5
|
+
import { Authorization } from "../../Authorization"
|
|
6
|
+
import { Merchant } from "../../Merchant"
|
|
7
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier"
|
|
8
|
+
import { Transaction } from "../../Transaction"
|
|
9
|
+
import { Batch } from "../Batch"
|
|
10
|
+
import { Fee } from "../Fee"
|
|
11
11
|
|
|
12
12
|
export interface Refund extends Omit<Refund.Creatable, "settlement"> {
|
|
13
13
|
status: "succeeded" | "failed"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import { Authorization } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { Authorization } from "../../Authorization"
|
|
4
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier"
|
|
5
|
+
import { Batch } from "../Batch"
|
|
6
6
|
|
|
7
7
|
export interface Unknown extends Omit<Unknown.Creatable, "settlement"> {
|
|
8
8
|
status: "succeeded" | "failed"
|
|
@@ -1,26 +1,57 @@
|
|
|
1
|
+
import { gracely } from "gracely"
|
|
2
|
+
import { isoly } from "isoly"
|
|
3
|
+
import { isly } from "isly"
|
|
4
|
+
import { Transaction } from "../../Transaction"
|
|
5
|
+
import { Cancel as EntryCancel } from "./Cancel"
|
|
6
|
+
import { Capture as EntryCapture } from "./Capture"
|
|
1
7
|
import { Creatable as EntryCreatable } from "./Creatable"
|
|
2
|
-
import {
|
|
3
|
-
import { fromCreatable } from "./fromCreatable"
|
|
4
|
-
import { fromLegacy as entryFromLegacy } from "./fromLegacy"
|
|
5
|
-
import { Entry as LegacyEntry } from "./Legacy"
|
|
6
|
-
import { Succeeded as EntrySucceeded } from "./Succeeded"
|
|
8
|
+
import { Refund as EntryRefund } from "./Refund"
|
|
7
9
|
import { Summary as EntrySummary } from "./Summary"
|
|
8
|
-
import {
|
|
10
|
+
import { Unknown as EntryUnknown } from "./Unknown"
|
|
9
11
|
|
|
10
|
-
export type Entry =
|
|
12
|
+
export type Entry = Entry.Cancel | Entry.Capture | Entry.Refund | Entry.Unknown
|
|
11
13
|
export namespace Entry {
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
+
export import Cancel = EntryCancel
|
|
15
|
+
export import Capture = EntryCapture
|
|
16
|
+
export import Refund = EntryRefund
|
|
17
|
+
export import Unknown = EntryUnknown
|
|
18
|
+
export type Type = "unknown" | "refund" | "capture" | "cancel"
|
|
19
|
+
export import Summary = EntrySummary
|
|
20
|
+
export import Creatable = EntryCreatable
|
|
21
|
+
export function from(creatable: Entry.Creatable, transaction: Transaction | gracely.Error | string): Entry {
|
|
22
|
+
let result: Entry
|
|
23
|
+
const created = isoly.DateTime.now()
|
|
24
|
+
if (!Transaction.type.is(transaction) || transaction.status != "finalized")
|
|
25
|
+
result = { status: "failed", reason: reason(creatable, transaction), ...creatable, created }
|
|
26
|
+
else
|
|
27
|
+
switch (creatable.type) {
|
|
28
|
+
case "capture":
|
|
29
|
+
result = Capture.from(creatable)
|
|
30
|
+
break
|
|
31
|
+
case "refund":
|
|
32
|
+
result = Refund.from(creatable, transaction)
|
|
33
|
+
break
|
|
34
|
+
default:
|
|
35
|
+
result = { ...creatable, status: "failed", reason: "Entry type not implemented yet.", created }
|
|
36
|
+
break
|
|
37
|
+
}
|
|
38
|
+
return result
|
|
14
39
|
}
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
function reason(creatable: Entry.Creatable, transaction: Transaction | gracely.Error | string): string {
|
|
41
|
+
const result = []
|
|
42
|
+
!creatable.authorization && result.push("Missing authorization.")
|
|
43
|
+
if (gracely.Error.is(transaction))
|
|
44
|
+
result.push(`gracely error: ${JSON.stringify(transaction)}`)
|
|
45
|
+
else if (typeof transaction != "string")
|
|
46
|
+
result.push(`Transaction ${transaction.id} on account ${transaction.accountId} unable to be finalized.`)
|
|
47
|
+
else
|
|
48
|
+
result.push(transaction || "No reason provided")
|
|
49
|
+
return result.join("\n")
|
|
17
50
|
}
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const fromLegacy = entryFromLegacy
|
|
25
|
-
export const from = fromCreatable
|
|
51
|
+
export const type = isly.union<Entry, Entry.Cancel, Entry.Capture, Entry.Refund, Entry.Unknown>(
|
|
52
|
+
Entry.Cancel.type,
|
|
53
|
+
Entry.Capture.type,
|
|
54
|
+
Entry.Refund.type,
|
|
55
|
+
Entry.Unknown.type
|
|
56
|
+
)
|
|
26
57
|
}
|
package/Settlement/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ export namespace Settlement {
|
|
|
40
40
|
entries: { count: 0 },
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
export function compile(settlement: Settlement, entries:
|
|
43
|
+
export function compile(settlement: Settlement, entries: Settlement.Entry[]): Settlement {
|
|
44
44
|
const result = { ...settlement }
|
|
45
45
|
for (const entry of entries) {
|
|
46
46
|
switch (entry.status) {
|
package/Transaction/Incoming.ts
CHANGED
|
@@ -26,7 +26,7 @@ export namespace Incoming {
|
|
|
26
26
|
reference: TransactionReference.type.optional(),
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
export function fromRefund(entry: Settlement.Entry.Creatable
|
|
29
|
+
export function fromRefund(entry: Settlement.Entry.Refund.Creatable, card: Rail.Address.Card): Incoming {
|
|
30
30
|
const [currency, amount] = entry.amount
|
|
31
31
|
return {
|
|
32
32
|
account: card,
|
package/Transaction/index.ts
CHANGED
|
@@ -335,7 +335,7 @@ export namespace Transaction {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
export function fromRefund(
|
|
338
|
-
refund: Settlement.Entry.Creatable
|
|
338
|
+
refund: Settlement.Entry.Refund.Creatable,
|
|
339
339
|
id: string,
|
|
340
340
|
account: { id: string; name: string; organization: string },
|
|
341
341
|
card: Rail.Address.Card,
|
|
@@ -2,16 +2,14 @@ import { cryptly } from "cryptly"
|
|
|
2
2
|
import { isoly } from "isoly"
|
|
3
3
|
import { isly } from "isly"
|
|
4
4
|
import { Authorization } from "../../Authorization"
|
|
5
|
-
import {
|
|
5
|
+
import { Unknown } from "../../Settlement/Entry/Unknown"
|
|
6
6
|
import { Identifier } from "../../Settlement/Identifier"
|
|
7
|
-
import { Transaction } from "../../Transaction"
|
|
8
7
|
import { Base } from "../Base"
|
|
9
8
|
|
|
10
9
|
export interface UnknownEntry extends Base {
|
|
11
10
|
type: "unknown-entry"
|
|
12
11
|
resource: Identifier
|
|
13
12
|
authorization?: Authorization["id"]
|
|
14
|
-
transaction?: Transaction["id"]
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export namespace UnknownEntry {
|
|
@@ -19,13 +17,12 @@ export namespace UnknownEntry {
|
|
|
19
17
|
type: isly.string("unknown-entry"),
|
|
20
18
|
resource: Identifier.type,
|
|
21
19
|
authorization: isly.fromIs("Authorization.id", cryptly.Identifier.is).optional(),
|
|
22
|
-
transaction: isly.string().optional(),
|
|
23
20
|
})
|
|
24
|
-
export function create(entry:
|
|
21
|
+
export function create(entry: Unknown, resource: Identifier): UnknownEntry {
|
|
25
22
|
return {
|
|
26
23
|
type: "unknown-entry",
|
|
27
24
|
resource,
|
|
28
|
-
|
|
25
|
+
authorization: entry.authorization?.id,
|
|
29
26
|
date: isoly.Date.now(),
|
|
30
27
|
}
|
|
31
28
|
}
|
|
@@ -6,6 +6,7 @@ import { Card } from "./Card";
|
|
|
6
6
|
export type Operation = Card | OperationAuthorization;
|
|
7
7
|
export declare namespace Operation {
|
|
8
8
|
function fromAuthorization(authorization: Authorization, status: OperationAuthorization.Status): Operation;
|
|
9
|
-
function fromEntry(entry: Entry
|
|
9
|
+
function fromEntry(entry: Entry): Operation | undefined;
|
|
10
|
+
function fromEntryStatus(status: Exclude<Entry.Type, "unknown">): OperationAuthorization.Status;
|
|
10
11
|
const type: isly.Type<Card | OperationAuthorization>;
|
|
11
12
|
}
|
|
@@ -14,16 +14,25 @@ export var Operation;
|
|
|
14
14
|
}
|
|
15
15
|
Operation.fromAuthorization = fromAuthorization;
|
|
16
16
|
function fromEntry(entry) {
|
|
17
|
-
return entry.
|
|
17
|
+
return entry.type == "unknown"
|
|
18
18
|
? undefined
|
|
19
19
|
: {
|
|
20
20
|
type: "authorization",
|
|
21
|
-
id: entry.transaction ?? "unknown",
|
|
22
|
-
status: entry.type
|
|
21
|
+
id: (entry.type != "refund" ? entry.authorization?.id : entry.transaction?.id) ?? "unknown",
|
|
22
|
+
status: Operation.fromEntryStatus(entry.type),
|
|
23
23
|
created: isoly.DateTime.now(),
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
Operation.fromEntry = fromEntry;
|
|
27
|
+
function fromEntryStatus(status) {
|
|
28
|
+
const statusConverter = {
|
|
29
|
+
capture: "captured",
|
|
30
|
+
cancel: "cancelled",
|
|
31
|
+
refund: "refunded",
|
|
32
|
+
};
|
|
33
|
+
return statusConverter[status];
|
|
34
|
+
}
|
|
35
|
+
Operation.fromEntryStatus = fromEntryStatus;
|
|
27
36
|
Operation.type = isly.union(Card.type, OperationAuthorization.type);
|
|
28
37
|
})(Operation || (Operation = {}));
|
|
29
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Card/Operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAI7B,MAAM,KAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Card/Operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAI7B,MAAM,KAAW,SAAS,CA4BzB;AA5BD,WAAiB,SAAS;IACzB,SAAgB,iBAAiB,CAAC,aAA4B,EAAE,MAAqC;QACpG,OAAO;YACN,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,aAAa,EAAE,EAAE,IAAI,aAAa,CAAC,WAAW,EAAE,EAAE,IAAI,SAAS;YACnE,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;SAC7B,CAAA;IACF,CAAC;IAPe,2BAAiB,oBAOhC,CAAA;IACD,SAAgB,SAAS,CAAC,KAAY;QACrC,OAAO,KAAK,CAAC,IAAI,IAAI,SAAS;YAC7B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACA,IAAI,EAAE,eAAe;gBACrB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,SAAS;gBAC3F,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7C,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;aAC5B,CAAA;IACL,CAAC;IATe,mBAAS,YASxB,CAAA;IACD,SAAgB,eAAe,CAAC,MAAsC;QACrE,MAAM,eAAe,GAA0E;YAC9F,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,UAAU;SAClB,CAAA;QACD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;IAPe,yBAAe,kBAO9B,CAAA;IACY,cAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAA;AACvE,CAAC,EA5BgB,SAAS,KAAT,SAAS,QA4BzB"}
|
|
@@ -42,5 +42,5 @@ export declare namespace Changes {
|
|
|
42
42
|
fee: number;
|
|
43
43
|
charge?: number;
|
|
44
44
|
}): Changes;
|
|
45
|
-
function fromRefund(settlement: string | undefined, refund: Settlement.Entry.Creatable
|
|
45
|
+
function fromRefund(settlement: string | undefined, refund: Settlement.Entry.Refund.Creatable, charge: number | undefined, sum: Sum): Changes;
|
|
46
46
|
}
|
|
@@ -12,5 +12,5 @@ export declare namespace Creatable {
|
|
|
12
12
|
const types: readonly ["incoming", "finalizeIncoming", "outgoing", "finalizeOutgoing", "authorization", "capture", "charge", "refund", "cancel", "remove", "collect", "manual", "fund", "legacy", "adjustBuffer"];
|
|
13
13
|
type Type = typeof types[number];
|
|
14
14
|
const type: import("isly/dist/cjs/object").IslyObject<Creatable, object>;
|
|
15
|
-
function fromRefund(account: string, settlement: string, entry: Settlement.Entry.Creatable
|
|
15
|
+
function fromRefund(account: string, settlement: string, entry: Settlement.Entry.Refund.Creatable): Creatable;
|
|
16
16
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
-
import { Amount } from "
|
|
3
|
-
import { Authorization } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { Amount } from "../../Amount";
|
|
3
|
+
import { Authorization } from "../../Authorization";
|
|
4
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier";
|
|
5
|
+
import { Batch } from "../Batch";
|
|
6
|
+
import { Fee } from "../Fee";
|
|
7
7
|
export interface Cancel extends Omit<Cancel.Creatable, "settlement"> {
|
|
8
8
|
status: "succeeded" | "failed";
|
|
9
9
|
reason?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
import { Amount } from "
|
|
4
|
-
import { Authorization } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Amount } from "../../Amount";
|
|
4
|
+
import { Authorization } from "../../Authorization";
|
|
5
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier";
|
|
6
|
+
import { Batch } from "../Batch";
|
|
7
|
+
import { Fee } from "../Fee";
|
|
8
8
|
export var Cancel;
|
|
9
9
|
(function (Cancel) {
|
|
10
10
|
let Creatable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cancel.js","sourceRoot":"../","sources":["Settlement/Entry/Cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAQ5B,MAAM,KAAW,MAAM,CA2BtB;AA3BD,WAAiB,MAAM;IAUtB,IAAiB,SAAS,CAUzB;IAVD,WAAiB,SAAS;QACZ,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;YAC1C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC3B,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC5C,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACnC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;YACxB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC9B,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,UAAU,EAAE,oBAAoB,CAAC,IAAI;SACrC,CAAC,CAAA;IACH,CAAC,EAVgB,SAAS,GAAT,gBAAS,KAAT,gBAAS,QAUzB;IACY,WAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAS;QACtE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzD,UAAU,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE;KAChD,CAAC,CAAA;AACH,CAAC,EA3BgB,MAAM,KAAN,MAAM,QA2BtB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
-
import { Amount } from "
|
|
3
|
-
import { Authorization } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { Amount } from "../../Amount";
|
|
3
|
+
import { Authorization } from "../../Authorization";
|
|
4
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier";
|
|
5
|
+
import { Batch } from "../Batch";
|
|
6
|
+
import { Fee } from "../Fee";
|
|
7
7
|
export interface Capture extends Omit<Capture.Creatable, "settlement"> {
|
|
8
8
|
status: "succeeded" | "failed";
|
|
9
9
|
reason?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
2
|
import { isly } from "isly";
|
|
3
|
-
import { Amount } from "
|
|
4
|
-
import { Authorization } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Amount } from "../../Amount";
|
|
4
|
+
import { Authorization } from "../../Authorization";
|
|
5
|
+
import { Identifier as SettlementIdentifier } from "../../Settlement/Identifier";
|
|
6
|
+
import { Batch } from "../Batch";
|
|
7
|
+
import { Fee } from "../Fee";
|
|
8
8
|
export var Capture;
|
|
9
9
|
(function (Capture) {
|
|
10
10
|
function from(creatable) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Capture.js","sourceRoot":"../","sources":["Settlement/Entry/Capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAQ5B,MAAM,KAAW,OAAO,CAgCvB;AAhCD,WAAiB,OAAO;IACvB,SAAgB,IAAI,CAAC,SAAoB;QACxC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAA;IAC5E,CAAC;IAFe,YAAI,OAEnB,CAAA;IAWD,IAAiB,SAAS,CAWzB;IAXD,WAAiB,SAAS;QACZ,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;YAC1C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;YAC5B,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACjC,aAAa,EAAE,aAAa,CAAC,IAAI;YACjC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE;YACxB,GAAG,EAAE,GAAG,CAAC,IAAI;YACb,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,UAAU,EAAE,oBAAoB,CAAC,IAAI;SACrC,CAAC,CAAA;IACH,CAAC,EAXgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAWzB;IACY,YAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAU;QACvE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAChC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;QACpE,UAAU,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE;KAChD,CAAC,CAAA;AACH,CAAC,EAhCgB,OAAO,KAAP,OAAO,QAgCvB"}
|
|
@@ -1,54 +1,9 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { Identifier as SettlementIdentifier } from "../Identifier";
|
|
8
|
-
import { Entry as LegacyEntry } from "./Legacy";
|
|
9
|
-
export type Creatable = Creatable.Known | Creatable.Unknown;
|
|
2
|
+
import { Cancel as EntryCancel } from "./Cancel";
|
|
3
|
+
import { Capture as EntryCapture } from "./Capture";
|
|
4
|
+
import { Refund as EntryRefund } from "./Refund";
|
|
5
|
+
import { Unknown as EntryUnknown } from "./Unknown";
|
|
6
|
+
export type Creatable = EntryCancel.Creatable | EntryCapture.Creatable | EntryRefund.Creatable | EntryUnknown.Creatable;
|
|
10
7
|
export declare namespace Creatable {
|
|
11
|
-
|
|
12
|
-
card: string;
|
|
13
|
-
transaction?: string;
|
|
14
|
-
account: string;
|
|
15
|
-
approvalCode: string;
|
|
16
|
-
merchant: Merchant;
|
|
17
|
-
acquirer: Acquirer;
|
|
18
|
-
reference: string;
|
|
19
|
-
batch: Batch;
|
|
20
|
-
fee: Fee;
|
|
21
|
-
amount: Amount;
|
|
22
|
-
settlement: SettlementIdentifier;
|
|
23
|
-
}
|
|
24
|
-
namespace Base {
|
|
25
|
-
const type: import("isly/dist/cjs/object").IslyObject<Base, object>;
|
|
26
|
-
}
|
|
27
|
-
interface Capture extends Base {
|
|
28
|
-
type: "capture";
|
|
29
|
-
}
|
|
30
|
-
namespace Capture {
|
|
31
|
-
const type: import("isly/dist/cjs/object").IslyObject<Capture, Base>;
|
|
32
|
-
function fromLegacy(maybeLegacy: Capture | LegacyEntry.Capture.Creatable): Capture;
|
|
33
|
-
}
|
|
34
|
-
interface Refund extends Base {
|
|
35
|
-
type: "refund";
|
|
36
|
-
}
|
|
37
|
-
namespace Refund {
|
|
38
|
-
const type: import("isly/dist/cjs/object").IslyObject<Refund, Base>;
|
|
39
|
-
function fromLegacy(maybeLegacy: Refund | LegacyEntry.Refund.Creatable): Refund;
|
|
40
|
-
}
|
|
41
|
-
type Known = Capture | Refund;
|
|
42
|
-
namespace Known {
|
|
43
|
-
const type: isly.Type<Capture | Refund>;
|
|
44
|
-
function fromLegacy(maybeLegacy: Creatable.Known | LegacyEntry.Capture.Creatable | LegacyEntry.Refund.Creatable): Creatable.Known;
|
|
45
|
-
}
|
|
46
|
-
interface Unknown extends Partial<Base> {
|
|
47
|
-
type: "unknown";
|
|
48
|
-
data: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
namespace Unknown {
|
|
51
|
-
const type: import("isly/dist/cjs/object").IslyObject<Unknown, object>;
|
|
52
|
-
}
|
|
53
|
-
const type: isly.Type<Capture | Refund | Unknown>;
|
|
8
|
+
const type: isly.Type<EntryCancel.Creatable | EntryCapture.Creatable | EntryRefund.Creatable | EntryUnknown.Creatable>;
|
|
54
9
|
}
|