|
1
|
import crypto from "crypto" |
|
2
|
|
|
3
|
import { |
|
4
|
AuthorizePaymentInput, |
|
5
|
AuthorizePaymentOutput, |
|
6
|
CancelPaymentInput, |
|
7
|
CancelPaymentOutput, |
|
8
|
CapturePaymentInput, |
|
9
|
CapturePaymentOutput, |
|
10
|
RetrieveAccountHolderInput, |
|
11
|
RetrieveAccountHolderOutput, |
|
12
|
CreateAccountHolderInput, |
|
13
|
CreateAccountHolderOutput, |
|
14
|
DeleteAccountHolderInput, |
|
15
|
DeleteAccountHolderOutput, |
|
16
|
DeletePaymentInput, |
|
17
|
DeletePaymentOutput, |
|
18
|
GetPaymentStatusInput, |
|
19
|
GetPaymentStatusOutput, |
|
20
|
InitiatePaymentInput, |
|
21
|
InitiatePaymentOutput, |
|
22
|
ProviderWebhookPayload, |
|
23
|
RefundPaymentInput, |
|
24
|
RefundPaymentOutput, |
|
25
|
RetrievePaymentInput, |
|
26
|
RetrievePaymentOutput, |
|
27
|
UpdatePaymentInput, |
|
28
|
UpdatePaymentOutput, |
|
29
|
WebhookActionResult, |
|
30
|
} from "@medusajs/framework/types" |
|
31
|
import { |
|
32
|
AbstractPaymentProvider, |
|
33
|
PaymentActions, |
|
34
|
PaymentSessionStatus, |
|
35
|
} from "@medusajs/framework/utils" |
|
36
|
|
|
37
|
export class SystemPaymentProvider extends AbstractPaymentProvider { |
|
38
|
static identifier = "system" |
|
39
|
|
|
40
|
async getStatus(_): Promise<string> { |
|
41
|
return "authorized" |
|
42
|
} |
|
43
|
|
|
44
|
async getPaymentData(_): Promise<Record<string, unknown>> { |
|
45
|
return {} |
|
46
|
} |
|
47
|
|
|
48
|
async initiatePayment( |
|
49
|
input: InitiatePaymentInput |
|
50
|
): Promise<InitiatePaymentOutput> { |
|
51
|
return { data: {}, id: crypto.randomUUID() } |
|
52
|
} |
|
53
|
|
|
54
|
async getPaymentStatus( |
|
55
|
input: GetPaymentStatusInput |
|
56
|
): Promise<GetPaymentStatusOutput> { |
|
57
|
throw new Error("Method not implemented.") |
|
58
|
} |
|
59
|
|
|
60
|
async retrievePayment( |
|
61
|
input: RetrievePaymentInput |
|
62
|
): Promise<RetrievePaymentOutput> { |
|
63
|
return {} |
|
64
|
} |
|
65
|
|
|
66
|
async authorizePayment( |
|
67
|
input: AuthorizePaymentInput |
|
68
|
): Promise<AuthorizePaymentOutput> { |
|
69
|
return { data: {}, status: PaymentSessionStatus.AUTHORIZED } |
|
70
|
} |
|
71
|
|
|
72
|
async updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput> { |
|
73
|
return { data: {} } |
|
74
|
} |
|
75
|
|
|
76
|
async deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput> { |
|
77
|
return { data: {} } |
|
78
|
} |
|
79
|
|
|
80
|
async capturePayment( |
|
81
|
input: CapturePaymentInput |
|
82
|
): Promise<CapturePaymentOutput> { |
|
83
|
return { data: {} } |
|
84
|
} |
|
85
|
|
|
86
|
async retrieveAccountHolder( |
|
87
|
input: RetrieveAccountHolderInput |
|
88
|
): Promise<RetrieveAccountHolderOutput> { |
|
89
|
return { id: input.id } |
|
90
|
} |
|
91
|
|
|
92
|
async createAccountHolder( |
|
93
|
input: CreateAccountHolderInput |
|
94
|
): Promise<CreateAccountHolderOutput> { |
|
95
|
return { id: input.context.customer.id } |
|
96
|
} |
|
97
|
|
|
98
|
async deleteAccountHolder( |
|
99
|
input: DeleteAccountHolderInput |
|
100
|
): Promise<DeleteAccountHolderOutput> { |
|
101
|
return { data: {} } |
|
102
|
} |
|
103
|
|
|
104
|
async refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput> { |
|
105
|
return { data: {} } |
|
106
|
} |
|
107
|
|
|
108
|
async cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput> { |
|
109
|
return { data: {} } |
|
110
|
} |
|
111
|
|
|
112
|
async getWebhookActionAndData( |
|
113
|
data: ProviderWebhookPayload["payload"] |
|
114
|
): Promise<WebhookActionResult> { |
|
115
|
return { action: PaymentActions.NOT_SUPPORTED } |
|
116
|
} |
|
117
|
} |
|
118
|
|
|
119
|
export default SystemPaymentProvider |