#Nyxi

1 messages ยท Page 1 of 1 (latest)

hoary wigeonBOT
pine stone
#

The requests don't make it to Stripe, so I can't provide request IDs

#
let paymentSheet = PaymentSheet(paymentIntentClientSecret: data.paymentIntent.clientSecret, configuration: configuration)
        
        paymentSheet.present(from: self) { [weak self] paymentResult in
            
            guard let self = self else {
                return
            }
            
            switch paymentResult {
            case .completed:
                
                // success
                
            case .canceled:
                
                break
                
            case .failed(let error):
                
               // I end here immediately with error being the inspected object above
                
            }
        }
grim furnace
#

Hi ๐Ÿ‘‹ can you help me understand what your application is trying to do when it encounters those errors? thank you, looking.

pine stone
#

StripePaymentSheet 23.6.0 is the version

grim furnace
#

Hm, it's interesting that the errors seem to change from complaining about a private key to complaining about a publishable key.

pine stone
#

It should be this intent: pi_3Mw4qEL7ilRdQXxE1tVSvSTA

#

I swear this worked a week ago, but I did not take note of which version of the SDK I used then

#

I also never had to set STPAPIClient.shared.publishableKey = "pk_test_xx" before, I only just set StripeAPI.defaultPublishableKey = "pk_test_xx"

#

Although setting it of course didn't help

grim furnace
#

I don't think I'm going to be able to glean much insight from the Payment Intent since the request you're referring to would have been blocked pretty early if it didn't include a valid key.

pine stone
#

Sure, it was just so you could see that it's a valid intent in test mode

#

I'm not sure how to proceed here though, I don't think I'm doing anything wrong

grim furnace
#

Looking at our code samples, it does look like STPAPIClient.shared.publishableKey is what we're recommending to use there.

Where in your flow do things crash? Is it the presentment of the payment sheet, or when payment method details are provided and the payment is attempted to be submitted?

pine stone
#

It's not crashing, it just returns the error immediaiely as the sheet is being presented. It loads for probably half a second, then dismisses according to the code above.

pine stone
#

And adding a card in other parts of the app works fine

#

tokenizing a card for instance

olive granite
#

you can get this error if you're not providing a valid ephemeral key too(the error message is unfortunately generic)

pine stone
#

Alright, let me investigate this

olive granite
#

so if you look at how you create the PaymentSheet.Configuration() and specifically customer on that, what is the value you're passing to ephemeralKeySecret

pine stone
#

It is returned by the API and generated by the API (fetched from Stripe) on each request for it. I don't store or cache it anywhere

#

So not sure how it would be invalid

#

Like this, on each request for my payment info:

$ephemeralKey = $stripe->ephemeralKeys->create(['customer' => "customer_id_here",], ['stripe_version' => '2022-08-01']);
olive granite
#

our docs for how the key should be handled are unfortunately quite bad

#

for example in that code, the value you should send to the frontend should be $ephemeralKey->secret; I think, let me check

pine stone
#

Hmm. I didn't make changes to this and it did work previously.

#

Maybe the PHP SDK was updated

#

You know what, I am actually doing it wrong in one place but not another

#

So maybe that's why

#

Hold on

olive granite
#

we don't push updates to the SDK really so that wouldn't apply unless you updated your installation

but yeah, the value you want is $ephemeralKey->secret and should look like ek_test_xxxx, that's the string to pass to ephemeralKeySecret in the PaymentSheet.configuration

pine stone
#

Yeah this is it

#

It just serializes the entire object to JSON

#

thank you, weakly typed PHP

#

But only in one of the 6 places I do this, which was this one, hence the confusion

#

Let me just fix this

olive granite
#

I see, if you're passing something like {id:"xxxx", secret:"ek_test_xxxx",...} that indeed won't work

pine stone
#

Exactly

olive granite
#

but yeah it's unfortunate that the error message from the point in the SDK that tries to make the request and fails is generic and points to the publishable key in the error string, I have raised that feedback before

pine stone
#

weird how I didn't get warning for this in the IDE. It's a string argument and an EphemeralKey object

pine stone
#

Works now

hoary wigeonBOT