Service to help create update and find PaymentIntents for paying down bookings.

Uses stripe PaymentIntents as an impl detail, but uses business and order id details to validate Whether payment intents are correctly being created

interface PaymentsService {
    cancelPaymentIntent(paymentIntentId: string): Promise<void>;
    captureIntentAndPersistPayment(
        payment: models.checkout.BookingCreateParams.Payment,
        orderId: string,
    ): Promise<SavedBooking>;
    captureStripeIntent(
        paymentIntentId: string,
        paymentAmount: number,
        orderId: string,
    ): Promise<CaptureChargeResponse>;
    createAffirmCharge(
        paymentToken: string,
        paymentAmount: number,
        orderId: string,
    ): Promise<CaptureChargeResponse>;
    createAutoConfirmPaymentIntent(
        params: AutoConfirmPaymentIntentCreateParams,
    ): Promise<AutoConfirmPaymentIntentInfo>;
    createPaymentIntent(
        params: PaymentIntentCreateParams,
    ): Promise<PaymentIntentInfo>;
    createRefund(
        paymentId: string,
        isCharge: boolean,
        amount: number,
    ): Promise<RefundResponse>;
    finalizePaymentIntent(
        paymentIntentId: string,
        params: PaymentIntentUpdateParams,
    ): Promise<FinalizedPaymentIntentInfo>;
    findPaymentIntent(paymentIntentId: string): Promise<PaymentIntentInfo>;
    getVerifiedPaymentProcessorEvent(
        payload: string,
        signature: string,
    ): Promise<Event>;
    listBookingsForAutomaticPayment(): Promise<SavedBooking[]>;
    makeBookingPayment(
        bookingId: string,
        makePaymentParams: MakePaymentParams,
    ): Promise<SavedBooking>;
    preparePaymentIntent(
        paymentIntentId: string,
        params: PaymentIntentUpdateParams,
    ): Promise<PaymentIntentInfo>;
    processAutomaticPayment(booking: SavedBooking): Promise<SavedBooking>;
    processPaymentProcessorEvent(event: Event): Promise<void>;
    savePayment(
        orderId: string,
        payment: SavePaymentParams,
    ): Promise<SavedBooking>;
}

Methods

  • Creates a refund for a payment in Stripe

    Parameters

    • paymentId: string

      Payment identifier.

    • isCharge: boolean

      By default paymentId is a paymentIntentId. Set this param as true to indicate that paymentId is a chargeId.

    • amount: number

      Amount to refund. Can refund only up to the remaining, unrefunded amount of the charge.

    Returns Promise<RefundResponse>