#Dai - Apple Pay

1 messages · Page 1 of 1 (latest)

light estuary
proper cape
#

one moment

#

the payment id is pi_3Ley9dFyuEVpH6pT1FEWU24M

#

should I be looking for the request id on the connected account?

#

if so, the payment intent request was...

#

req_5puACYSNAmGcDe

#

I am using a stripe.js payment element and the confirmPayment method

light estuary
#

THanks for sharing, give me couple of minutes while I investigate

proper cape
#

I can;t see a request id for the payment confirm

#

with my iphone connected to my mac and viewing the console I see a 400 error

#

on that stripe endpoint

light estuary
proper cape
#

I was inspecting the javascript console on the web app when runing in iphone

#

this is my code,

#

const appearance = {
theme: 'stripe'
};

Elements = StripeApi.elements({ clientSecret: StripePaymentIntentSecret, appearance : appearance });
var element = Elements.create('payment');
element.mount('#payment-element');
#

then to confirm

#

StripeApi.confirmPayment({
elements: Elements,
confirmParams: {
// Return URL where the customer should be redirected after the PaymentIntent is confirmed.
return_url: $('button#pay-now').data('success-url'),
},
})
.then(function (result) {
if (result.error) {
// Inform the customer that there was an error.
removeWaitOverlay();
$('div#error-element').html(
"<p><span class='fa fa-exclamation-circle'></span> " + result.error.message + " Please try a different payment method.</p>"
);
$('div#error-element').removeClass('no-display');
}
});

#

its all quite simple and works fine for card payments in teseting

#

now I'm trying to do a real apple pay payment in production

#

I can see apple pay display something quickly then it dissapears

#

when I expect the iphone js console on my mac is see the 400 error on that stripe endpoint

#

no error is caught by the confirmPayment method so the screen just hangs

#

with my wait indicator on it.

#

bear in mind I might nbo be on latest version of api

#

but I'm hoping not to go through an upgrade right now

#

at the very least I would expect an error to be returned so I can handle it?

light estuary
proper cape
#

req_pSspKyzCKId8Ib

#

i have more info

#

the 400 error says

#

"before you canb start using apple pay on the web you neet to first register your domain

#

I have done this at my platform, level

#

karlekko helped with this error when it was in dev and said it would be ok in prod

#

@dawn solstice hi

#

not sure if you remember but a couple of weeks ago we chatted about apple pay in dev not working

dawn solstice
#

I probably remember yes, I help a lot of people though

proper cape
#

of course

#

so I have rolled into production but its still not working

dawn solstice
#

ok I'll look in a little while

#

just coming online and have to catch up on all the other Discord threads too

proper cape
#

can I ask first - is it possible to use apple pay with connected account and direct charges?

dawn solstice
#

yes, completely, lots of platforms do it

proper cape
#

direct, not setination

#

*destination

dawn solstice
#

yes

proper cape
#

ok cool

dawn solstice
#

right so I'm looking. Can you give me a link to the page with the problem where Apple Pay doesn't work?

proper cape
#

You mean the page on my platform?

dawn solstice
#

I mean the page you're looking at in Safari right now where you expect to see Apple Pay and it's not appearing, so yes I suppose!

proper cape
#

so it won't work that way for you because it is part of an anonymous checkout flow - you add product to basket, checkout stage 1 completing some customer details then go to payment - the payment page won't work unless you create an order and this is production

#

I can copy the exact javascript I use. its very simple

dawn solstice
#

don't need the JS yet

#

ok

#

if you want this to work you need to do the following :

proper cape
#

Here is what I currently do.

I initialise stripe like this...
var StripeApi = Stripe(StripePublicApiKey, { stripeAccount: StripeConnectedAccountID, apiVersion: '2020-08-27' });

#

I create and mount a payment element

#

Elements = StripeApi.elements({ clientSecret: StripePaymentIntentSecret, appearance : appearance });
var element = Elements.create('payment');
element.mount('#payment-element');

#

I confirm payment using that element

#

StripeApi.confirmPayment({
elements: Elements,
confirmParams: {
// Return URL where the customer should be redirected after the PaymentIntent is confirmed.
return_url: $('button#pay-now').data('success-url'),
},
})
.then(function (result) {
if (result.error) {
// Inform the customer that there was an error.
removeWaitOverlay();
$('div#error-element').html(
"<p><span class='fa fa-exclamation-circle'></span> " + result.error.message + " Please try a different payment method.</p>"
);
$('div#error-element').removeClass('no-display');
}
});

#

This works with cards, and google pay in dev

#

but was unable to test apple pay as per our last conversation.

dawn solstice
#

ok

proper cape
#

Will this approach simply not work for applepay? Reading your link on the payment request button it seems like I need to register each connected acccount for applepay

dawn solstice
#

so like I said you need to register the domain and you didn't. Did you miss that reply?

proper cape
#

register my domain?

dawn solstice
#

you do yes

proper cape
#

I have done that

dawn solstice
#

no

#

register it on the connected account

dawn solstice
#

each one

proper cape
#

oh!

#

ok

#

I think I follow, one sec

#

Can I do this in the dashboard?

dawn solstice
#

no

#

has to be done through the specific API call I mentioned

#

if you try to do it in the dashboard for the connected account you'll actually break things, unfortunately. You must do exactly what the docs describe to the letter, or nothing works

proper cape
#

so i see there is a .net way to do this, is this a one time thing?

#

or can I do this using the stripe.js

#

at the time of mounting payment menthods etc

dawn solstice
proper cape
#

there is yes

#

will this work with what I have done though? or do I have to change to use a payment-request-button?

dawn solstice
dawn solstice
dawn solstice
proper cape
#

got it ok. now - is there a way I can exclude apple pay from a payment element if a connected account hasn't yet had this done?

#

so I can make sure it doesn't fail disgracefully

#

like when I create the payment element in js

dawn solstice
proper cape
#

hmm, it is showing up for me

#

hence the error i saw

dawn solstice
#

that shouldn't happen as far as I know, unless you're forcing it somehow

#

I'd again need to see the specific page with the problem to say more

#

Safari has an internal function canMakePayments which we check and it should return false if the domain is not registered properly, in which case the Element wouldn't display it. But again, might be something specific about your setup, hard to say.

proper cape
#

ok, i'll get on with registering my domain with the connected accounts

dawn solstice
#

Dai - Apple Pay

proper cape
#

quick q

#

is it ok to do this registration step in dev?

spiral gazelle
#

Hi! I'm taking over this thread.

#

For tests payments, then yes you can register your domain in test mode.

proper cape
#

thanks

#

but applepay won;t actually work in dev right?

#

but I can make sure registration works at least

spiral gazelle
#

but applepay won;t actually work in dev right?
What do you mean by "dev"? Stripe has two mode: test mode and live mode.

proper cape
#

i mean in test mode on dev (development) web sites running on localhost apple pay won;t work?

#

or using ngrok

spiral gazelle
#

You can test Apple Pay in test mode. But you need to use an httpS URL for it to work.

proper cape
#

even with connected accounts?

spiral gazelle
#

We try to make Stripe test mode and live mode as similar as possible. So if something is possible in live mode, it should also be possible in test mode.

proper cape
#

ok so I should set up the .well-known/apple-developer-merchantid-domain-association in test mode for the stripe accounts I use for testing

spiral gazelle
#

yes

proper cape
#

I've just regsietered the wrong domain on a connected account - can I just overwrwrite this using the same command?

spiral gazelle
#

I think you can have multiple domain verified with Apple.

proper cape
#

is there a way we can look at old messages here on discord?

#

I recall karlekko saying sometin about apple pay doesnt work in test mode for connected accountds

spiral gazelle
#

Hum... there is a search bar in the top right, but the search on Discord is not that great.

proper cape
#

so here is me paraphrasing what I recall karlekko saying

#

applepay can't be tested for connect accounts

#

but it will work in live mode

#

as an example, i am using a loacl web site accessible via ngrok

#

I have added the ngrok domain magaroo.ngrok.io to the applepay settings for my dev stripe account in test mode

#

I have registrerd the same domain with some connected accounts

#

but when I try and checkout using apple pay it still doersn;t seem to work or raise a request

#

id

#

yes it still fails to create an apple pay session

dawn solstice
#

I need a link to the page really.

#

you still haven't registered the domain

dawn solstice
proper cape
#

right - sorry for my confusion here

#

and by regsiter the domain you mean register the domain on the connected account

#

not the hosting of the apple file

#

apple-devloper-merchantid-domain-association

#

so basically there is not point in registering connected accounts for the platform apple pay domain in any test environment at all, i just need to do it on the live site

dawn solstice
#

hosting the file is not the same thing as registering no. Registering is the API call I linked an hour ago

proper cape
#

yes and that needs to be in live mode so no point testing,

dawn solstice
proper cape
#

ok

#

final q (i hope) is the hosted file the same for all domains?

dawn solstice
#

yes the file itself hosted on the domain is the same

proper cape
#

thanks

proper cape
#

frustratingly this still doesn;t want to work after registering the connected account with the domain

#

still get the register domain error despite having regsitered it

#

server side using the stripe .net library and got 200 ok in response

dawn solstice
#

one sec

#

ok, the domain is registered fine.

#

sorry to keep asking, do you have a link to the page that has the problem? It's really the fastest way for me to help you. Create a test account for me if you need to

proper cape
#

you can access it without an account, you just need to add something to your basket

#

go to

dawn solstice
proper cape
#

this is a store that is enabeld for anonymous checkout

#

add something , click on the basket, checkout, add some detaisl then you get to payment page

dawn solstice
#

ok, give me a bit

proper cape
#

np

dawn solstice
#

can you give me an address that works?

#

ok I just used the same West Sussex address as the merchant(was using a London one)

proper cape
#

ah yes sorry

dawn solstice
#

ah

#

you have to register the domain for Apple Pay using www.magaroo.com not just magaroo.com, it has to match exactly the domain name that will appear in the browser.

proper cape
#

thats so strange

#

i was sure www always redirects to flat domain

dawn solstice
#

it's how this works in Apple+Stripe, every subdomain has to be registered separately

proper cape
#

so if i reghister bnoath is that ok?

dawn solstice
#

let's not debate it for now, can you just do the registration and confirm it works?

proper cape
#

both#

dawn solstice
proper cape
#

great, on it

#

thanks

#

do I have to do it seperately, that is with new applePayDomainService instance each time

#

or can is use ApplePayDomain.Create m,ultiple times with diff request options

dawn solstice
#

either way works

proper cape
#

cool

proper cape
#

wohho

#

woohoo - finally worked

#

thanks!!!

dawn solstice
#

awesome!