#vm1172

1 messages · Page 1 of 1 (latest)

prime iceBOT
crude glade
#

Hey toby, nothing shows up in the logs [1]

[1] https://dashboard.stripe.com/logs

previously I had certificate issues which required me to create a new Apple Pay Processing Certificate [attached screenshot] and requestID req_CDKWVtZbfr5WFf:

invalid_request_error
We were unable to decrypt your request. Please make sure you've generated and uploaded your Apple Pay certificate at https://dashboard.stripe.com/settings/payments/apple_pay.

now, I can't even get to the stage of the apple pay lifecycle which triggers the POST /v1/tokens

#

I also couldn't find the error The data couldn't be read because it isn't in the correct format

defined anywhere in the Stripe Node library and its pretty vague so I don't know where to start. I can share the code if needed

@cloud saffron let me know if you need anything else, thanks for the help

cloud saffron
#

Hey đź‘‹ sorry for the delay, the server is a bit busy at the moment. Thank you for the additional details, taking a look.

#

Hm, sorry, I'm a bit lost, I'm not the best at iOS dev work and may need to pull in a teammate, but let me start with trying to get some clarity.

The data couldn't be read because it isn't in the correct format
I don't see this error in the request that you referenced. Can you help me understand where you're seeing it surfaced? If that's coming directly from our API, that may be why you didn't find it in a library, I'm pretty sure those messages come right from the API rather than being in our SDKs.

crude glade
#

I'm seeing it surfaced when calling const { paymentIntent, error } = await confirmPlatformPayPayment(clientSecret, params)

and then the error returned is the one listed above

#

I call confirmPlatformPayPayment while triggering onPress on the PlatformPayButton

crude glade
cloud saffron
#

ahh gotcha

#

Hm, version 0.28.0 of our React Native SDK doesn't appear to be pinned as the expected version for a given Expo SDK version. What is Expo SDK version are you on?

crude glade
#

"expo": "~49.0.10",

#

I installed @stripe/stripe-react-native via this command, so it should be the most recent package which Expo supports

ran this command

  • npx expo install @stripe/stripe-react-native
cloud saffron
prime iceBOT
crude glade
cloud saffron
#

Hm, alright, just wanted to check that as I know Expo can be finicky if it doesn't have the right versions.

crude glade
#

yeah ofcourse no worries

#

hey, sorry to bother you, any update on this?

cloud saffron
#

Sorry, no, I don't know what's going on here and am looping in a teammate to look.

crude glade
#

okay no worries, appreciate it

frail plinth
#

Hey, still looking in to this. It looks like this can happen around XCode upgrades if the plist format changes. So it may be worth checking that your file matches the one expected by your current version of XCode https://stackoverflow.com/questions/45748140/xcode-9-distribution-build-fails-because-format-of-exportoptions-plist-has-chang

#

I see that a colleague asked to write in to our support so that we could take a deeper look, were you able to do that? Want to check on anything that may have happened in that conversation

#

Also, just to double check, have you printed out your client secret and the params that you are passing in to see that they are set to what you expect them to be?

crude glade
#

hey Pompey, thanks for the response, give me a second

crude glade
crude glade
crude glade
# frail plinth Also, just to double check, have you printed out your client secret and the para...

printing out everything right now below -

{"clientSecret": "pi_3NyFpvCa1hzW9vNX0St9L4M1_secret_B8fLglMDkIlrJd8wIOHYF3kMh", "error": {"code": "Failed", "declineCode": null, "localizedMessage": "The data couldn’t be read because it isn’t in the correct format.", "message": "The data couldn’t be read because it isn’t in the correct format.", "stripeErrorCode": null, "type": null}, "params": {"applePay": {"cartItems": [Array], "currencyCode": "USD", "merchantCapabilities": [Array], "merchantCountryCode": "US", "requiredBillingContactFields": [Array], "requiredShippingAddressFields": [Array], "shippingMethods": [Array]}}, "paymentIntent": undefined}
#

params

    const params = {
      applePay: {
        cartItems: cart,
        merchantCountryCode: ALLOWED_COUNTRY,
        currencyCode: CURRENCY.toUpperCase(),
        shippingMethods,
        requiredShippingAddressFields: [
          PlatformPay.ContactField.Name,
          PlatformPay.ContactField.PhoneNumber,
          PlatformPay.ContactField.PostalAddress
        ],
        requiredBillingContactFields: [PlatformPay.ContactField.PostalAddress],
        merchantCapabilities: [
          ApplePayMerchantCapability.Supports3DS,
          ApplePayMerchantCapability.SupportsCredit,
          ApplePayMerchantCapability.SupportsDebit
        ]
      }
    }
frail plinth
#

Interesting, "The data couldn’t be read because it isn’t in the correct format." is in your params before you even call confirmPlatformPayPayment?

crude glade
#

I'm not entirely sure, but yes I think so. since once I call confirmPlatformPayPayment, that is where I receive the error from

glacial crane
#

đź‘‹ wasn't the issue with passing shippingMethods when calling confirm? We narrowed down on it a few days ago right?

crude glade
#

hey hanzo

#

yes we did narrow it down to shippingMethods, but the same issue cropped up again

glacial crane
#

Looking at the code you shared above, you're still passing that parameter in your confirm params

crude glade
#

i,e., removing shippingMethods still caused errors, so I added it back :/

{"clientSecret": "pi_3NyFzECa1hzW9vNX1wFre9vL_secret_Vuv7WIopT4tUIKpcRK6CrkuEM", "error": {"code": "Failed", "declineCode": null, "localizedMessage": "The data couldn’t be read because it isn’t in the correct format.", "message": "The data couldn’t be read because it isn’t in the correct format.", "stripeErrorCode": null, "type": null}, "params": {"applePay": {"cartItems": [Array], "currencyCode": "USD", "merchantCapabilities": [Array], "merchantCountryCode": "US", "requiredBillingContactFields": [Array], "requiredShippingAddressFields": [Array], "shippingMethods": [Array]}}, "paymentIntent": undefined}
glacial crane
#

what sort of errors?

crude glade
#
Stripe Apple Pay Error {"code": "Failed", "declineCode": null, "localizedMessage": "The data couldn’t be read because it isn’t in the correct format.", "message": "The data couldn’t be read because it isn’t in the correct format.", "stripeErrorCode": null, "type": null}
glacial crane
#

sorry I am confused, you said removing shippingMethods still caused errors

are you saying that you're seeing the same error if you remove that parameter or are you seeing a different error when you remove shippingMethods?

crude glade
#

yes im seeing the same error if i removed that parameter

#

shippingMethods wasn't the cause of the issue imo

glacial crane
#

the full error message you shared above

{"clientSecret": "pi_3NyFzECa1hzW9vNX1wFre9vL_secret_Vuv7WIopT4tUIKpcRK6CrkuEM", "error": {"code": "Failed", "declineCode": null, "localizedMessage": "The data couldn’t be read because it isn’t in the correct format.", "message": "The data couldn’t be read because it isn’t in the correct format.", "stripeErrorCode": null, "type": null}, "params": {"applePay": {"cartItems": [Array], "currencyCode": "USD", "merchantCapabilities": [Array], "merchantCountryCode": "US", "requiredBillingContactFields": [Array], "requiredShippingAddressFields": [Array], "shippingMethods": [Array]}}, "paymentIntent": undefined}

shippingMethods is present in the params.

I believe this is the same issue I asked you to write in about. It isn't really different from last time.

crude glade
#

trying this

    const params = {
      applePay: {
        cartItems: cart,
        merchantCountryCode: ALLOWED_COUNTRY,
        currencyCode: CURRENCY.toUpperCase(),
        // shippingMethods: [],
        requiredShippingAddressFields: [
          PlatformPay.ContactField.Name,
          PlatformPay.ContactField.PhoneNumber,
          PlatformPay.ContactField.PostalAddress
        ],
        requiredBillingContactFields: [PlatformPay.ContactField.PostalAddress],
        merchantCapabilities: [
          ApplePayMerchantCapability.Supports3DS,
          ApplePayMerchantCapability.SupportsCredit,
          ApplePayMerchantCapability.SupportsDebit
        ]
      }
    }

still errors out

glacial crane
#

what happens if you go back to just the three parameters like last time?

        merchantCountryCode: 'us',
        currencyCode: 'usd',```
crude glade
#

it works now

{"clientSecret": "pi_3NyG4KCa1hzW9vNX0i3rfbu6_secret_PZYsihvOpdrNerVlvFHqCTKGF", "error": undefined, "params": {"applePay": {"cartItems": [Array], "currencyCode": "usd", "merchantCountryCode": "us"}}, "paymentIntent": {"amount": 2000, "canceledAt": null, "captureMethod": "Automatic", "clientSecret": "pi_3NyG4KCa1hzW9vNX0i3rfbu6_secret_PZYsihvOpdrNerVlvFHqCTKGF", "confirmationMethod": "Automatic", "created": "1696606560000", "currency": "usd", "description": "<StripePayments.STPPaymentIntent: 0x10a629ae0; stripeId = pi_3NyG4KCa1hzW9vNX0i3rfbu6; amount = 2000; canceledAt = nil; captureMethod = Optional(\"automatic\"); clientSecret = <redacted>; confirmationMethod = Optional(\"automatic\"); countryCode = nil; created = 2023-10-06 15:36:00 +0000; currency = usd; description = nil; lastPaymentError = nil; linkSettings = nil; livemode = false; nextAction = nil; paymentMethodId = Optional(\"pm_1NyG4OCa1hzW9vNXsBccC8Zz\"); paymentMethod = nil; paymentMethodOptions = nil; paymentMethodTypes = Optional([\"card\"]); receiptEmail = nil; setupFutureUsage = nil; shipping = nil; sourceId = nil; status = Optional(\"succeeded\"); unactivatedPaymentMethodTypes = []>", "id": "pi_3NyG4KCa1hzW9vNX0i3rfbu6", "lastPaymentError": null, "livemode": false, "nextAction": null, "paymentMethod": null, "paymentMethodId": "pm_1NyG4OCa1hzW9vNXsBccC8Zz", "receiptEmail": null, "shipping": null, "status": "Succeeded"}}
glacial crane
#

Cool

Try adding the additional parameters back in one by one

crude glade
#

it fails when I add back requiredShippingAddressFields with the following item PlatformPay.ContactField.PostalAddress

#

I will share the relevant code snippet with you now

<PlatformPayButton
          onPress={pay}
          onShippingContactSelected={async (contact) =>
            onShippingContactSelected(contact.shippingContact)
          }

onShippingContactSelected is used to calculate tax for the user and this callback is triggered whenever the user selects a shipping contact in the Apple Pay sheet IF ContactField.PostalAddress was included in the requiredShippingAddressFields array

#

my onShippingContactSelected function below:

  const onShippingContactSelected = async (shippingContact: ShippingContact) => {
    const postalCode = shippingContact.postalAddress.postalCode
    const { amount, normalizedTax } = await getTax(postalCode)
    const newCart: PlatformPay.CartSummaryItem[] = [
      {
        label: 'Subtotal',
        amount: amount.toString(),
        paymentType: PlatformPay.PaymentType.Immediate
      },
      {
        label: 'Tax',
        amount: normalizedTax.toString(),
        isPending: false,
        paymentType: PlatformPay.PaymentType.Immediate
      },
      {
        label: 'Shipping',
        amount: '0.00',
        isPending: false,
        paymentType: PlatformPay.PaymentType.Immediate
      },
      {
        label: 'Total',
        amount: (amount + normalizedTax).toString(),
        isPending: false,
        paymentType: PlatformPay.PaymentType.Immediate
      }
    ]
    setCart(newCart)
    const { error } = await updatePlatformPaySheet({
      applePay: {
        cartItems: newCart,
        shippingMethods: [],
        errors: []
      }
    })
    if (error !== undefined) console.error('onShippingContactSelected', error)
    const order = {
      subtotal: amount,
      tax: normalizedTax,
      total: amount + normalizedTax
    }
    const token = await getItem('token')
    await CheckoutSessionAPI.updatePaymentIntent(paymentIntentId, shippingContact, order, token)
  }
glacial crane
#

right, this is why I asked you to write in the last time we worked on this issue as this requires a deeper investigation.
We'll need to reproduce and look into exactly what's going on.

This isn't something we can do on discord while working with multiple different folks at the same time. If you can create a very simple app with just the minimal code that's required to reproduce the issue and write in via our support then we can investigate with proper context and help you much better.

Debugging complex topics live on discord is not super easy especially when it comes down to tricky bugs like this.

prime iceBOT
crude glade
#

ah got it, i thought when you mentioned to write in you were intimating to just shoot over a message on updating types or generic error messages but that makes sense apologies

#

i'll rephrase, its likely that its an issue from my side, and that the cart item data is getting mangled when using updatePlatformPaySheet and updatePaymentIntent (which is a BE endpoint)

#

I'll try creating a simple app to repro the issue

glacial crane
#

No worries 👍 appreciate it

crude glade
#

to close this out, so currently you don't have any leads on what might be causing the issue yeah?

glacial crane
#

yeah I don't see anything wrong with the logic you currently have.
It might be something tiny we're missing/overlooking