#JCoDog - issuing elements PHP
1 messages · Page 1 of 1 (latest)
These elements are meant for a front-end application, which is expected to be running some javascript
So yes you'll need at least some client script for using the issuing elements on your page for your customers/users
Yes, I see. I am just trying to figure how to make it run, but I think I will make an express localhost version of the site for now as I only need information about one card.
I assume you can declare stripe in the script tag within html for this to work?
Yep! You can see that done here:
https://stripe.com/docs/js/including
https://stripe.com/docs/js/initializing
JCoDog - issuing elements PHP
What is that blue bar? Is that what the issuing card pin display looks like when mounted?
What happens if you get rid of the style that you are providing?
is it meant to be in a div or a paragraph?
I think it should be in its own script tag. Can you try moving your code out of the tag that sources stripe.js?
<script>
const pubKey = ....
</script>```
Which line of code is throwing that error?
I am still not seeing the Pin number or the copy button
How do I display these using the mount thing as I am not sure it is attatching to the elements in the html document
do I need to add it to an iframe?
The mounting is what creates the iframe here.
I am still not seeing the Pin number or the copy button
Does this mean that that previous exception about ephemeralKey and nonce went away or is this still the same issue?
yes
its not working, I have done the dom element as it shows in the stripe.js reference but it is not working.
<div class="wrapper">
<div class="content">
<div class="store-item" style="text-align: center;">
<label>Pin:
<div id="card-number"></div>
</label>
</div>
</div>
</div>
<script src="https://js.stripe.com/v3/"></script>
<script async>
async function getCard() {
const pubkey = "";
var stripe = Stripe(pubkey);
const cardId = '';
// Use Stripe.js to create a nonce
const nonceResult = await stripe.createEphemeralKeyNonce({
issuingCard: cardId,
});
if (nonceResult.error) {
console.error(nonceResult.error);
}
const nonce = await nonceResult.nonce;
// Call your ephemeral key creation endpoint to fetch the ephemeral key
const ephemeralKeyResult = await fetch('', {
method: 'POST',
body: `cardId=${cardId}&nonce=${nonce}`,
});
const ephemeralKeyResponse = await ephemeralKeyResult.json();
const ephemeralKeySecret = await ephemeralKeyResponse.ephemeralKeySecret;
const elements = stripe.elements();
const cardNumber = await elements.create('issuingCardPinDisplay', {
issuingCard: cardId,
nonce: nonce,
ephemeralKeySecret: ephemeralKeySecret,
});
cardNumber.mount('#card-number');
const cardNumberCopy = await elements.create('issuingCardCopyButton', {
toCopy: 'pin',
style: {
base: {
fontSize: '12px',
lineHeight: '24px',
},
},
});
// Once again, mount the elements onto DOM elements in your web application
cardNumberCopy.mount('#card-number-copy');
}
getCard()
</script>```
When you say not working. Do you mean you get that exception and stripe.js errors out? Or are you past that exception, no errors in the console, and the DOM element is there but not visible?
Gotcha, thank you for clarifying. Looking in to what can cause that error
something about line one column one? So cardId?
ok well I told it to log the ephemeral key stuff and its logged nothing
So is this endpoint wrong?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Somehow I am passing in unknown variables
Hi there 👋 taking over for @lone turtle
Can you summarize any outstanding questions? The thread is a little all over the place and I'm unsure if anything is outstanding
I fixed that but it is not sending the variables from the client-side through the serverside endpoint.
As shown here
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
This is the endpoint
This is where I call to the endpoint.
The endpoint is not returning the ephemeral key so the entire process of retrieving the card is not working.
give me a sec, catching up
first question
1/ can you add logs to your server-side PHP code to ensure that your PHP endpoint is being called correctly? just add multiple log lines through your endpoint , i.e. before and after the Stripe related code
I know it is being called correctly because it triggers the event in the logs on stripe
yeah but please do add the logs, the Stripe part might be executing fine but I want to ensure you get to the last line of your PHP code
yeah that works, or if you have a server console, then just writing to it
which part errors, is it the Stripe API request?
or a part of your code after it?
sorry I'm a bit confused as you had said the Stripe part works correctly earlier, so the Stripe part is error'ing out? What is the request ID? You can get it from your https://dashboard.stripe.com/logs/ page
it isnt getting the information from payload
payload is $payload->body right?
you mean the payload your frontend is sending, right? I am not entirely sure as I'm not a PHP expert but I recommend logging out both$payloadand$payload->bodyto confirm which has the data you're sending