Files
medusa-store/packages/modules/payment/src/providers/system.ts

112 lines
2.6 KiB
TypeScript

import crypto from "crypto"
import {
AuthorizePaymentInput,
AuthorizePaymentOutput,
CancelPaymentInput,
CancelPaymentOutput,
CapturePaymentInput,
CapturePaymentOutput,
CreateAccountHolderInput,
CreateAccountHolderOutput,
DeleteAccountHolderInput,
DeleteAccountHolderOutput,
DeletePaymentInput,
DeletePaymentOutput,
GetPaymentStatusInput,
GetPaymentStatusOutput,
InitiatePaymentInput,
InitiatePaymentOutput,
ProviderWebhookPayload,
RefundPaymentInput,
RefundPaymentOutput,
RetrievePaymentInput,
RetrievePaymentOutput,
UpdatePaymentInput,
UpdatePaymentOutput,
WebhookActionResult,
} from "@medusajs/framework/types"
import {
AbstractPaymentProvider,
PaymentActions,
PaymentSessionStatus,
} from "@medusajs/framework/utils"
export class SystemProviderService extends AbstractPaymentProvider {
static identifier = "system"
async getStatus(_): Promise<string> {
return "authorized"
}
async getPaymentData(_): Promise<Record<string, unknown>> {
return {}
}
async initiatePayment(
input: InitiatePaymentInput
): Promise<InitiatePaymentOutput> {
return { data: {}, id: crypto.randomUUID() }
}
async getPaymentStatus(
input: GetPaymentStatusInput
): Promise<GetPaymentStatusOutput> {
throw new Error("Method not implemented.")
}
async retrievePayment(
input: RetrievePaymentInput
): Promise<RetrievePaymentOutput> {
return {}
}
async authorizePayment(
input: AuthorizePaymentInput
): Promise<AuthorizePaymentOutput> {
return { data: {}, status: PaymentSessionStatus.AUTHORIZED }
}
async updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput> {
return { data: {} }
}
async deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput> {
return { data: {} }
}
async capturePayment(
input: CapturePaymentInput
): Promise<CapturePaymentOutput> {
return { data: {} }
}
async createAccountHolder(
input: CreateAccountHolderInput
): Promise<CreateAccountHolderOutput> {
return { id: input.context.customer.id }
}
async deleteAccountHolder(
input: DeleteAccountHolderInput
): Promise<DeleteAccountHolderOutput> {
return { data: {} }
}
async refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput> {
return { data: {} }
}
async cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput> {
return { data: {} }
}
async getWebhookActionAndData(
data: ProviderWebhookPayload["payload"]
): Promise<WebhookActionResult> {
return { action: PaymentActions.NOT_SUPPORTED }
}
}
export default SystemProviderService