Stripe Checkout New
No need to design payment forms from scratch. Stripe Checkout offers a beautiful, customizable payment flow that works great across desktop and mobile. When you use Checkout, you’re always up-to-date, with no extra code required.
Explore Checkout
Total control with Stripe.js
Stripe.js securely transmits card details from browsers to Stripe. Use it to control every pixel of the experience and let Stripe take care of the pesky processing and compliance.This is very simple coding for integrate stripe payment in php. please look the copy the code and paste in your working file. READ MORE
<?php require 'stripe/lib/Stripe.php';
if ($_POST) {
// Stripe::setApiKey("pk_test_RLTidE9AhJ0DENd5pLCieMpm");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
Stripe_Charge::create(array("amount" => 10,
"currency" => "usd",
"card" => $_POST['stripeToken']));
$success = 'Your payment was successful.'.$_POST['stripeToken'];
}
catch (Exception $e) {
$error = $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
// This identifies your website in the createToken call below
Stripe.setPublishableKey('pk_test_RLTidE9AhJ0DENd5pLCieMpm');
var stripeResponseHandler = function(status, response) {
var $form = $('#payment-form');
if (response.error) {
// Show the errors on the form
$form.find('.payment-errors').text(response.error.message);
$form.find('button').prop('disabled', false);
} else {
// token contains id, last4, and card type
var token = response.id;
// Insert the token into the form so it gets submitted to the server
$form.append($('<input type="hidden" name="stripeToken" />').val(token));
// and re-submit
$form.get(0).submit();
}
};
jQuery(function($) {
$('#payment-form').submit(function(e) {
var $form = $(this);
// Disable the submit button to prevent repeated clicks
$form.find('button').prop('disabled', true);
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from submitting with the default action
return false;
});
});
</script>
</head>
<body>
<h1>Charge $10 with Stripe</h1>
<span class="payment-errors"><?= $error ?></span>
<span class="payment-success"><?= $success ?></span>
<form action="" method="POST" id="payment-form">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_RLTidE9AhJ0DENd5pLCieMpm"
data-amount="50"
data-name="online Pay with stripe"
data-description="Your Card items payment"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-currency="USD">
</script>
</form>
</body>
</html>
Great content! Super high-quality! If you want to learn more about PHP, you can learn from here -
ReplyDeleteHow to display PDF file in PHP from database
How to read CSV file in PHP and store in MySQL
Create and Download Word document PHP