#krusty-paymentsheet-help

1 messages Β· Page 1 of 1 (latest)

fathom yoke
#

Hello! Can I ask you to provide a lot more context/details on what you need help with?

mystic steeple
#

absolutely, im playing with Stripes example app in the ExampleCustomCheckoutViewController

#

i wpould like to test out the FlowController UI using my own stripe account, my test user

#

and try out adding new payment methods

#

to said user

fathom yoke
#

Sorry, which exact library, which language, which platform

mystic steeple
#

sorry about that, this is for iOS

#

using swift UIKit

fathom yoke
#

So you are using stripe-ios?

mystic steeple
#

testing PaymentSheet component

#

and FlowController

fathom yoke
#

Sorry there are multiple separate libaries and you're really deep in your question already without the high level info

mystic steeple
#

yes thats correct, stripe-ios

fathom yoke
#

Okay so what's the problem?

mystic steeple
#

as im using my own PublishableKey

#

and my own customerId

#

im setting the key this was
STPAPIClient.shared.publishableKey = publishableKey

#

and i get the following error

#

Error Domain=com.stripe.lib Code=51 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:ErrorMessageKey=You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/., com.stripe.lib:StripeErrorTypeKey=invalid_request_error, NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:hintKey=No valid API key provided. Set STPAPIClient.shared().publishableKey to your publishable key, which you can find here: https://stripe.com/docs/keys, com.stripe.lib:StripeErrorCodeKey=}

fathom yoke
#

Please take 20 steps back lol

mystic steeple
#

haha

fathom yoke
#

1/ Which exact app are you using, can you link me to the exact one?

mystic steeple
#

yes exactly that one

#

which send back the paymentIntent, customer, etc

#

i commented out the request and declared the values with my own

#

at the step when this gets calles
PaymentSheet.FlowController.create

#

is when the error happens

#

hope that makes more sense

fathom yoke
#

yep that helps let me have a look

mystic steeple
#

also on a similar note, the configuration.customer takes as input 'ephemeralKeySecret' and i cant seem to find a way to fetch this key, in case you could share some context about it, highly appreciated

fathom yoke
#

an ephemeral key is a key specific to your Customer and you create it via the API, usually with a back end like the glitch

mystic steeple
#

do you happen to have the reference to the API for it

fathom yoke
#

There's no API reference for it sadly

mystic steeple
#

ok thanks

#

i can see answers to my questions about teh ephemeralKey there, thank you

fathom yoke
#

that way you can use your own key/customer id/etc.

#

it's... convoluted, to say the least

mystic steeple
#

hehe, ok i can take convoluted

#

really appreciate the help

#

Thank you πŸ™

fathom yoke
#

Are you unblocked now? I was able to run the example myself too after having remix-ed the Glitch

mystic steeple
#

i was just figuring out glitch

fathom yoke
#

yeah it's not easy to grasp their UI

mystic steeple
#

added mypk and sk

fathom yoke
#

but once you remix, you edit the environment variables and it's already running

mystic steeple
#

ran the thing

#

and now i was trying to curl to the server

fathom yoke
mystic steeple
fathom yoke
#

you can see the PReview at the bottom and yeah that's how you get the URL so you got this already

#

mostly you just need to change let backendCheckoutUrl in the code

mystic steeple
#

i just did the curl in my terminal

#

but its just sitting there,

#

yeap thats what i figured

#

this happened when i did it from terminal

#

curl -X POST https://lizard-silly-scorpion.glitch.me/checkout 130 ↡
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>πŸ‘» Site didn't respond</title>
<meta name="viewport" content="initial-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="https://glitch.com/edit/themes/cosmos.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
<script src="https://glitch.com/edit/error-page.js"></script>
</head>
<body class="ghost-border">
<div class="container">

  <h1>
    Site didn't respond
  </h1>

  <p>
    Something in the code caused it to close the connection before providing a response.
  </p>

  <p>
    If this is your project please visit us at <a href="https://support.glitch.com">support.glitch.com</a> for assistance.
  </p>

  <div class="actions">
    <a href="https://glitch.com">
      <div class="glitch-logo bird">
      </div>
    </a>
  </div>
</div>

<canvas id="stars"></canvas>

</body>
</html>

#

im probably missing something but i should be able to figure it out

#

thanks

fathom yoke
#

yeah the same works for me (with my own glitch URL)

#

is your code running already, is there anything in the Logs panel?

#

(also careful sharing the URL since once it works anyone can get your Secret API key from it

mystic steeple
#

(node:401) UnhandledPromiseRejectionWarning: Error: Invalid Stripe API version: 2020-08-27;automatic_payment_methods_beta=v1;. You do not have permission to pass this beta header: automatic_payment_methods_beta. If you have any questions, we can help at https://support.stripe.com/.

fathom yoke
#

hum

#

are you passing that beta header anywhere?

#

it's not in my remix-ed version at least

mystic steeple
#

i just added my pk and sk to the .env file and that was it

fathom yoke
#

can you look at server.js and see what the /checkout route looks like? Mine is // An endpoint for your checkout app.post("/checkout", async (req, res) => { var stripe = require("stripe")(process.env.secret_key);

mystic steeple
#

ok now it seems to be working

fathom yoke
#

weird

mystic steeple
#

Performing headless installation
Total install time: 9935ms
Node server listening on port 3000!

fathom yoke
#

perfect!

mystic steeple
#

πŸ₯³

fathom yoke
#

okay got to run but @delicate crag can help if you have follow up questions!

mystic steeple
#

thank you

#

have a good one

#

Hello @delicate crag

delicate crag
#

Hello πŸ‘‹

mystic steeple
#

hi, koopajah was helping me with glitch

#

im getting this weird error when i try to call curl -X POST https://.......

#

(node:322) UnhandledPromiseRejectionWarning: Error: Invalid Stripe API version: 2020-08-27;automatic_payment_methods_beta=v1;. You do not have permission to pass this beta header: automatic_payment_methods_beta. If you have any questions, we can help at https://support.stripe.com/.
at Function.generate (/rbd/pnpm-volume/b53783ae-4316-4cba-97de-681e905f174e/node_modules/.registry.npmjs.org/stripe/8.96.0/node_modules/stripe/lib/Error.js:39:16)
at IncomingMessage.res.once (/rbd/pnpm-volume/b53783ae-4316-4cba-97de-681e905f174e/node_modules/.registry.npmjs.org/stripe/8.96.0/node_modules/stripe/lib/StripeResource.js:190:33)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

#

looking inside my server.js i can see this:
const stripe = require("stripe")(
process.env.secret_key, /* https://stripe.com/docs/keys#obtain-api-keys */
{ apiVersion: '2020-08-27;automatic_payment_methods_beta=v1;' }
);

Manage your API keys to authenticate requests with Stripe.

#

not sure if i need to adjust this

delicate crag
#

Can you remove automatic_payment_methods_beta=v1;?

mystic steeple
#

yes, let me try

#

ok that did the trick

#

im getting a response.....

#

thanks!!!!

delicate crag
#

That's great πŸ˜„

mystic steeple
#

ok im able to do what i wanted

#

thank you so much

#

Issue solved!!!!!

#

have a great rest of your day

delicate crag
#

Awesome! Have a nice day to you as well 🀩

mystic steeple
#

quick question

#

hope you are still around

#

im able to add CC using the payment sheet

#

but the paymentSheet only displays CC

#

paymentIntent is calling
automatic_payment_methods: {
enabled: true,
}

#

i just checked my dashboard and i have klarna, affirm and afterPay turned on

#

shouldnt i be able to see those payment methods as well

#

i also have ACH Direct Debit turned on

delicate crag
mystic steeple
#

sure thing

delicate crag
#

Payment Intent ID (pi_xxx) also works

mystic steeple
#

pi_3LINE4Hnen00B3RT1lqRBfSb

#

thats the last one

#

mm im seeing in the sourceTpy only card is listed

#

i assumed that
automatic_payment_methods: {
enabled: true,
}
would take the enabled methods from the dashboard

#

im guessing i need to add the paymentMethods by hand?

delicate crag
#

I'm checking your request, the payment methods available is dependent on the currency and sometimes country too

mystic steeple
#

ok you ar eright

delicate crag
#

The currency you set is in EUR:

  • Affirm - only supports USD
  • Klarna - the account is a US account, so it can only process USD
  • AfterPay - depends on customer country
  • ACH Direct Debit - only supports USD
mystic steeple
#

i have it with currency europe

#

yes yes

#

ok tht did the trick, thank you so much

delicate crag
#

No problem! Happy to help πŸ™‚

mystic steeple
#

if i wanted to pass the payment methods as a list

#

could i do something like

#

const paymentIntent = await stripe.paymentIntents.create({
amount: 2500,
currency: "usd",
customer: customerId,
payment_method_type: {

}

});

#

and pass it as an array

#

i do it in CURL to create a paymentIntent as:
-d "payment_method_types[]"=affirm
-d "payment_method_types[]"=afterpay_clearpay
-d "payment_method_types[]"=klarna

delicate crag
#

You can do it with payment_method_types. We generally recommend to use automatic payment methods, so that you don't have to compute it yourself if you support multiple currencies

mystic steeple
#

just USD

#

i see a benefit to do it manually in case i want to run experiemnts

#

and just have buckets of users with certain payment methods

delicate crag
#

Yup, you definitely can use payment_method_types param for finer payment method control

mystic steeple
#

thank you