#samsara-applepay-appears

1 messages · Page 1 of 1 (latest)

dawn gyroBOT
orchid ibex
#

samsara-applepay-appears

#

@timid rock d oyou have more details?

#

I'd rather not load a random website

timid rock
#

Yup I see it there

#

it's not a random website, it's a food ordering app for Brevard Zoo

#

SSL and https certified

#

What kind of details? We've added the domain association file and are hosting it at the higher level domain

#

but we have subdomains where the actual payment form is, but that shouldn't be an issue right?

orchid ibex
#

that is 100% the issue

#

the exact domain you render this on has to be verified

#

so you need to add eat.sparkd.com as a domain

#

did you do that part?

timid rock
#

oh i guess it took some time to register, its working now

orchid ibex
#

Are you using Stripe Connect?

timid rock
#

Yup

orchid ibex
#

Did you register the domain on the connected account?

timid rock
#

Which one would be the connected account?

#

Oh the account Id we're using?

orchid ibex
#

I don't know what that sentence means sorry. And it depends a lot on your flow of funds. Can you explain exactly what you do?

timid rock
#

We have a main account that ties all these connect accounts together, and we have multiple "partners" or connect accounts that we're processing payments to depending on what restaurant the user has chosen

#

So if they're at denver zoo we're processing payments using that connect account, but if they're at maryland or brevard we use different connect account ids

orchid ibex
#

yeah sorry the vocabulary with Stripe is crucial to get right and drastically changes how this works

#

1/ What type of connected accounts do you use: Standard, Express or Custom?

timid rock
#

I believe it's standard

orchid ibex
#

2/ What type of flow of funds do you use? Destination Charges or Direct Charges?

timid rock
#

I believe direct charges

#

And another piece of info if it helps: Apple pay shows up in incognito mode (but doesn't let us process the payment), but it doesn't show up on a normal window in safari

orchid ibex
#

Yeah there are dozens of gotchas with Apple Pay. Like it shows on incognito because Safari doesn't let the website know if Apple Pay is configured or not (and Google does the opposite in Chrome)

#

3/ Are you doing this in live mode or test mode?

timid rock
#

We are testing both right now

#

But the accounts we're testing for apple pay are all live mode created accounts

orchid ibex
#

Okay we're making progress

#

4/ How exactly are you initializing Stripe.js client-side?

#

I looked at your website but it's all minified and I can't figure out where the code lives

timid rock
#

No worries, do you want the code for initilization?

orchid ibex
#

yes

timid rock
#

This is the loadstripe function we call, to get the stripePromise that I pass into the stripe provider like so:

    () =>
      loadStripe(stripeConfig.publicKey, {
        stripeAccount: getStripeAccountId(stripeConfig.accountId)
      }),
    [stripeConfig.accountId, stripeConfig.publicKey]
  );```
#

const PaymentsDrawer = ({ stripeAmount, email }: PaymentsDrawerProps) => {
  const { openPaymentsDrawer, setOpenPaymentsDrawer, submittingOrderDialog } =
    useCart();
  const { partnerConfig, stripeConfig } = usePartnerConfig();
  const partnerId = partnerConfig.partnerId;

  const [clientSecret, setClientSecret] = useState<string | undefined>();
  const stripePromise = useMemo(
    () =>
      loadStripe(stripeConfig.publicKey, {
        stripeAccount: getStripeAccountId(stripeConfig.accountId)
      }),
    [stripeConfig.accountId, stripeConfig.publicKey]
  );
  useEffect(() => {
    const asyncFetchClientSecret = async () => {
      const fetchedClientSecret = await fetchClientSecret(
        stripeAmount,
        partnerId,
        email
      );
      if (typeof fetchedClientSecret === 'string') {
        setClientSecret(fetchedClientSecret);
      } else {
        return;
      }
    };
    if (stripeAmount) {
      asyncFetchClientSecret();
    }
  }, [stripeAmount, email, partnerId]);

  return (
    <PaymentDrawer
      anchor="bottom"
      open={openPaymentsDrawer}
      onClose={() => setOpenPaymentsDrawer(false)}
      hideBackdrop={submittingOrderDialog.open}
    >
      {stripePromise && clientSecret && (
        <StripeProvider stripe={stripePromise} options={{ clientSecret }}>
          <PaymentForm clientSecret={clientSecret} />
        </StripeProvider>
      )}
    </PaymentDrawer>
  );
};

export default PaymentsDrawer;```
#

I have a useMemo in order to get around the unsupported prop change of the StripeProvider

orchid ibex
#

can you give me an example account id acct_123 where you're testing?

#

sorry that code is really tough to read for me, I barely understand React and you abstract a lot of stuff away from it and you useMemo is strange (it's likely normal, just not the kind of code I'm used to reading)

timid rock
#

No worries, the formatting came out weird

#

The account id we're testing is acct_1LowvdDTwu9XYxBB

orchid ibex
#

nah it's not the formatting, it's just React that makes no sense to me. Looking at that account though

#

cool so you never registered the domain on that account, like I thought :p

timid rock
#

So we have to register the apple domains for every connect account we use then? It's not good enough to just register on our primary account? It's weird because we've had this working before, was this a recent requirement change for connect accounts?

orchid ibex
#

correct, that's the first thing I explained

timid rock
#

Wait there might be some confusion in the way I'm explaining

orchid ibex
#

You are a platform A
You have connected accounts B, C and D
If you want to create Direct Charges on B, C and D, you need to make sure you have first registered the domain(s) on B, C and D

timid rock
#

Oh wow...that wasn't the case a few weeks ago. Like I could get Apple pay to show up and process a payment with that same account ID I posted locally running ngrok, by registering my ngrok domain. Now I'm not seeing it. So I have to login to those connect accounts and add the registration on those?

orchid ibex
#

no, absolutely not

#

the whole "login" is bad and would also never work (I mean we improved it but that's the wrong flow)

#

You have to use the API to register it. The doc I gave you above

timid rock
#

Ah okay thank you

#

So I would have to run that with each accounts secret key?

orchid ibex
#

no

#

you use your own platform secret key like you would for any calls on behalf of the connected account

timid rock
#

So is this not sufficient for that step?

orchid ibex
#

I don't know what you mean. That's just a picture of one Dashboard

timid rock
#

I guess I'm confused as to where the individual connect accounts come into play for the api call

orchid ibex
#

Again, if you have 100 connected accounts, and 3 domains, you have to register every single domain on every single connected account

#

ah

#

that doc is wrong

#

what the heck happened and who broke it GRRRRR

timid rock
#

Yup, the code reads ```var stripe = require("stripe")("sk_live_••••••••••••••••••••••••");

const domain = await stripe.applePayDomains.create({
domain_name: 'example.com',
});```

orchid ibex
#

This explains your confusion 😅

timid rock
#

Haha no worries, im always confused

orchid ibex
#

this is the section you need to look at. Looks like someone changed the link

timid rock
#

OHHH

orchid ibex
#

specifically curl https://api.stripe.com/v1/apple_pay/domains \ -u {PLATFORM_SECRET_KEY}: \ -H "Stripe-Account: {{CONNECTED_ACCOUNT_ID}}" \ -d domain_name="example.com"

#

the extra Stripe-Account

timid rock
#

Okay cool.

#

So I would do something like this ?

#
  -u {PLATFORM_SECRET_KEY}: \
  -H "Stripe-Account: {{acct_1LowvdDTwu9XYxBB}}" \
  -d domain_name="eat.sparkd.com"```
#

With our platform secret key of course, thats sk_blahblah

#

the ones that says sk and live?

orchid ibex
#

yes

timid rock
#

and do that for all connect accounts. gotcha. thanks so much

orchid ibex
#

sure thing!

timid rock
#

If I want to do this programmatically, would I do this on the backend? Somewhere in our stripe config?

#

I run this const domain = await stripe.applePayDomains.create({ domain_name: 'example.com', },{ stripe_account: '{{CONNECTED_ACCOUNT_ID}}', }); for every connect account id?

orchid ibex
#

yes

#

I mean as a platform you want to build a flow that lets you sync any domain on any connected account