# Accept a payment
Securely accept payments online.
Build a payment form or use a prebuilt checkout page to start accepting online payments.
# Stripe-hosted page
> This is a Stripe-hosted page for when platform is web and ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted.
Redirect to a Stripe-hosted payment page using [Stripe Checkout](https://docs.stripe.com/payments/checkout.md). See how this integration [compares to Stripe’s other integration types](https://docs.stripe.com/payments/online-payments.md#compare-features-and-availability).
#### Integration effort
Complexity: 2/5
#### Integration type
Redirect to Stripe-hosted payment page
#### UI customization
Limited customization
- 20 preset fonts
- 3 preset border radius
- Custom background and border color
- Custom logo
[Try it out](https://checkout.stripe.dev/)
First, [register](https://dashboard.stripe.com/register) for a Stripe account.
Use our official libraries to access the Stripe API from your application:
#### Ruby
```bash
# Available as a gem
sudo gem install stripe
```
```ruby
# If you use bundler, you can add this line to your Gemfile
gem 'stripe'
```
#### Python
```bash
# Install through pip
pip3 install --upgrade stripe
```
```bash
# Or find the Stripe package on http://pypi.python.org/pypi/stripe/
```
```python
# Find the version you want to pin:
# https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md
# Specify that version in your requirements.txt file
stripe>=5.0.0
```
#### PHP
```bash
# Install the PHP library with Composer
composer require stripe/stripe-php
```
```bash
# Or download the source directly: https://github.com/stripe/stripe-php/releases
```
#### Java
```java
/*
For Gradle, add the following dependency to your build.gradle and replace with
the version number you want to use from:
- https://mvnrepository.com/artifact/com.stripe/stripe-java or
- https://github.com/stripe/stripe-java/releases/latest
*/
implementation "com.stripe:stripe-java:30.0.0"
```
```xml
We appreciate your business! If you have any questions, please email orders@example.com.
``` Next, update the Checkout Session creation endpoint to use this new page: ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<{JSON.stringify(checkoutState.checkout.lineItems, null, 2)}
// A formatted total amount
Total: {checkoutState.checkout.total.total.amount}
);
}
};
```
## Collect customer email [Client-side]
#### HTML + JS
If you already pass in an existing [customer_email](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_email) or [Customer](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer) with a valid email set when creating the Checkout Session, you can skip this step.
If you implement your own email validation, you can pass in the validated email on [checkout.confirm](https://docs.stripe.com/js/custom_checkout/confirm) and skip this step.
Create an email input to collect your customer’s email address. Call [updateEmail](https://docs.stripe.com/js/custom_checkout/update_email) when your customer finishes the input to validate and save the email address.
Depending on the design of your checkout form, you can call `updateEmail` in the following ways:
- Directly before [submitting the payment](https://docs.stripe.com/payments/accept-a-payment.md#submit-payment). You can also call `updateEmail` to validate earlier, such as on input blur.
- Before transitioning to the next step, such as clicking a **Save** button, if your form includes multiple steps.
```html
```
```javascript
const checkout = stripe.initCheckout({clientSecret});
const loadActionsResult = await checkout.loadActions();
if (loadActionsResult.type === 'success') {
const {actions} = loadActionsResult;
const emailInput = document.getElementById('email');
const emailErrors = document.getElementById('email-errors');
emailInput.addEventListener('input', () => {
// Clear any validation errors
emailErrors.textContent = '';
});
emailInput.addEventListener('blur', () => {
const newEmail = emailInput.value;actions.updateEmail(newEmail).then((result) => {
if (result.error) {
emailErrors.textContent = result.error.message;
}
});
});
}
```
#### React
If you already pass in an existing [customer_email](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer_email) or [Customer](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer) with a valid email set when creating the Checkout Session, you can skip this step.
If you implement your own email validation, you can pass in the validated email on [confirm](https://docs.stripe.com/js/custom_checkout/react/confirm) and skip this step.
Create a component to collect your customer’s email address. Call [updateEmail](https://docs.stripe.com/js/custom_checkout/react/update_email) when your customer finishes the input to validate and save the email address.
Depending on the design of your checkout form, you can call `updateEmail` in the following ways:
- Directly before [submitting the payment](https://docs.stripe.com/payments/accept-a-payment.md#submit-payment). You can also call `updateEmail` to validate earlier, such as on input blur.
- Before transitioning to the next step, such as clicking a **Save** button, if your form includes multiple steps.
```jsx
import React from 'react';
import {useCheckout} from '@stripe/react-stripe-js/checkout';
const EmailInput = () => {
const checkoutState = useCheckout();
const [email, setEmail] = React.useState('');
const [error, setError] = React.useState(null);
if (checkoutState.type === 'loading') {
return (
{JSON.stringify(checkoutState.checkout.lineItems, null, 2)}
Subtotal: {checkoutState.checkout.total.subtotal.amount}
Shipping: {checkoutState.checkout.total.shippingRate.amount}
Total: {checkoutState.checkout.total.total.amount}
>
)}