#venkateshjsoft

1 messages ยท Page 1 of 1 (latest)

queen saffronBOT
warped parrot
#

Can you share how you're including and initializing Stripe.js?

carmine flare
#

<script src="https://js.stripe.com/v3/"></script>
<script src="client.js"></script>
<form id="payment-form">
<div class="form-row">
<label for="name">
Name
</label>
<input id="name" name="name" required>
</div>

<div class="form-row">
<label for="email">
Email
</label>
<input id="email" name="email" required>
</div>

<button id="submit-button">Pay with Sofort</button>

<!-- Display mandate acceptance text. -->
<div id="mandate-acceptance">
By providing your payment information and confirming this payment, you
authorise (A) Rocket Rides and Stripe, our payment service provider, to
send instructions to your bank to debit your account and (B) your bank to
debit your account in accordance with those instructions. As part of your
rights, you are entitled to a refund from your bank under the terms and
conditions of your agreement with your bank. A refund must be claimed
within 8 weeks starting from the date on which your account was debited.
Your rights are explained in a statement that you can obtain from your
bank. You agree to receive notifications for future debits up to 2 days
before they occur.
</div>
<!-- Used to display form errors. -->
<div id="error-message" role="alert"></div>
</form>

#

var stripe = Stripe('pk_test_51NG1TpDEdWHgNJdaFqirmgSdJvyCiuEfqDgRRCeJVQZDBtneKDOiN7dyC5HWFoTFC7bSvm79MVgaPerCMXun9Jcn00bi8PVRPm');
var accountholderName = document.getElementById('name');
var accountholderEmail = document.getElementById('email');

// Redirects away from the client
const {error} = stripe.confirmSofortPayment(
'{{PAYMENT_INTENT_CLIENT_SECRET}}',
{
payment_method: {
sofort: {
country: "DE"
},
billing_details: {
name: accountholderName.value,
email: accountholderEmail.value,
},
},
return_url: 'https://example.com/checkout/complete',
}
);

if (error) {
// Inform the customer that there was an error.
}

warped parrot
#

Are you then accessing this via an iframe somewhere else?

#

Otherwise I'm not sure I understand why you'd see that

carmine flare
#

im just trying to run the html and when i click the buttong im getting this error

#

im not accessing via iframe

queen saffronBOT
novel gulch
#

Hello ๐Ÿ‘‹
if I remember correctly, using Stripe.js requires HTTP server

#

You seem to be loading the HTML in the browser directly

#

in which case origin of the request is null

carmine flare
#

i can load it on the server

#

I added to the server now im getting different error

novel gulch
#

That's coming from your code and not Stripe

warped parrot
#

That's different error though when delivered over HTTP -- you'd need to look at the line in client.js that's throwing the error as hanzo mentioned that's your code

carmine flare
#

I coped client.js code from stripe documentation

novel gulch
#

We can't help you debug the code you copy paste from our docs.
You need to understand what the code is doing before you paste it in your app

#

I'd recommend trying to understand what the code is doing first

#

There are plenty of docs and tutorials on the web

carmine flare
#

I was told from other team members that copy paste the code will work straightaway

#

anyways I can check the code

#

thanks

novel gulch
#

๐Ÿ‘