title: Flutter_Stripe Package - Create Market Place with Payment Sheet (+Firebase Cloud Functions)
body: <p><strong>Quick Summary:
  I can not make the Payment Sheet compatible with a Market Place Concept.</strong></p>
  <p>I am implementing the flutter_payment Package to create an App where Vendors can offer Products which can be purchased by clients. I use Stripe Standard Accounts and a Direct Charge.</p>
  <p>The Working Process is:</p>
  <p>1.) User clics on Button and request Data from Firebase Cloud Functons.</p>
  <p>2.) Firebase Cloud Functions:
  2.1.) Create <strong>CustomerId</strong> (automatically on Platform Account)/ Get Customer Id from Firebase
  2.2.) Get ephemeralKeys from <strong>CustomerId</strong></p>
  <pre><code>   export const createEphemeralKey =
  functions.https.onCall(async (data, context) =&gt; {
    // Checking that the user is authenticated.
    if (!context.auth) {
      // Throwing an HttpsError so that the client gets the error details.
      throw new functions.https.HttpsError(
          &quot;failed-precondition&quot;,
          &quot;The function must be called while authenticated!&quot;
      );
    }
    const uid = context.auth.uid;
    try {
      if (!uid) throw new Error(&quot;Not authenticated!&quot;);
      // Get stripe customer id
      const FireCustomer = await admin.firestore()
          .collection(&quot;stripe_customers&quot;).doc(uid).get();
  
      const customer = FireCustomer.data()!.customer_id;
  
      const key = await stripe.ephemeralKeys.create(
          {customer},
          {apiVersion: &quot;2020-08-27&quot;}
      );
      console.log(&quot;The Key is&quot;);
      console.log(key);
      return key;
    } catch (error) {
      console.log(error);
    }
  }
  );
  </code></pre>
  <p>2.3.) Create Payment Intent</p>
  <pre><code>export const createPaymentIntent = functions.https.onCall(
  async (data, context) =&gt; {
    const amount:number = data.amount;
    console.log(&quot;The amount is&quot;);
    console.log(amount);
    const customerId = data.stripeCustomerId;
    const vendorId = data.vendorId;
    const fee:number = (amount* 8.1/100)| 0;
    console.log(&quot;here comes the fee&quot;);
    console.log(fee);
    console.log(vendorId);
    try {
      const paymentIntent = await stripe.paymentIntents.create({
        amount: amount,
        currency: &quot;eur&quot;,
        customer: customerId,
       // application_fee_amount: fee,
       // stripeAccount: vendorId,
      },
      );
      console.log(&quot;HEre comes the paymentIntent&quot;);
      console.log(paymentIntent);
      return paymentIntent;
    } catch (e) {
      return console.log(e);
    }
  });
  </code></pre>
  <p>3.) Then I pass the Data back to the App and pass them into the Payment Sheet</p>
  <pre><code> await Stripe.instance.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
          // Main params
          applePay: true,
          googlePay: true,
          style: ThemeMode.dark,
          testEnv: true,
          merchantCountryCode: 'DE',
          merchantDisplayName: 'Flutter Stripe Store Demo',
          customerId: stripeCustomerId,
          paymentIntentClientSecret: piSecret,
          customerEphemeralKeySecret: ephemeralKey),
          
    );
    await Stripe.instance.presentPaymentSheet();
  </code></pre>
  <p>Problem:
  The Client is created on the Platform Account and the payment data is stored there. If I try to create the Payment Intent with the &quot;stripeAccount: vendorId&quot; property ,the Customer Id is not being recognised as it's not being stored on the Connect account.</p>
  <p>Now what the Stripe Documentation says is to clone the Payment Method:</p>
  <p><a href="https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods" rel="nofollow noreferrer">https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods</a></p>
  <p>I can not clone the Payment Method because it is being created by flutter_stripe</p>
  <p>So I have no idea how to proceed as the flutter_stripe package is not well documented and the package is not compatible to the Stripe Documentation.
  Is a Payment Sheet a possible solution here at all?</p>
  <p>Thank you very much,</p>
  <p>Tim</p>