How to operate updates in cloud function after a success stripe payment? Such as adding a transaction doc or updating user balance

/// For mobile, use the native Stripe payment sheet to pay.
    ///
    /// First, initialize payment using the Stripe payment sheet.
    await Stripe.instance.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
        paymentIntentClientSecret: response['paymentIntent'],
        customerEphemeralKeySecret: response['ephemeralKey'],
        customerId: response['customer'],
        merchantDisplayName: 'FundEarly Deposit',
        googlePay: allowGooglePay
            ? PaymentSheetGooglePay(
                merchantCountryCode: 'AUD',
                currencyCode: currency,
                testEnv: !_isProd,
              )
            : null,
        applePay: isiOS && allowApplePay
            ? PaymentSheetApplePay(
                merchantCountryCode: 'AUD',
              )
            : null,
        style: themeStyle,
        appearance: PaymentSheetAppearance(
          primaryButton: PaymentSheetPrimaryButtonAppearance(
            colors: PaymentSheetPrimaryButtonTheme(
              light: PaymentSheetPrimaryButtonThemeColors(
                background: buttonColor,
                text: buttonTextColor,
              ),
              dark: PaymentSheetPrimaryButtonThemeColors(
                background: buttonColor,
                text: buttonTextColor,
              ),
            ),
          ),
        ),
      ),
    );

    /// Then show the payment sheet and confirm payment.
    await Stripe.instance.presentPaymentSheet();

    /// Finally, return the completed payment id to for record keeping.
    return StripePaymentResponse(paymentId: response['paymentId']);

Hello, I want to update my user account balance and add a transaction record with cloud function after a success stripe payment. Can I put them all in a cloud function?

1
3 replies