Эй, ребята, действительно, юниор dev здесь так извиняюсь, если это базовое: так что мне удалось заставить Stripe Checkout работать с PHP. Но я хотел избавиться от начальной кнопки Stripe Button, где обычно говорится: «Приступить к оплате» или «оплатить карточкой». Я просто хотел связать кнопку на моем сайте, чтобы перейти непосредственно к всплывающему окну Checkout. Мне было интересно, возможно ли это? Я включил php-файл и соответствующий html-код ниже.Stripe Checkout - PHP
index.php
<?php require_once('config.php'); ?>
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-name="The Boffins"
data-amount="25000"
data-currency="GBP"
data-description="Social Package"
data-image="images/Gentleman.gif"
data-label="Proceed to Payment"
data-panel-label="Only">
</script>
</form>
charge.php
<?php
require_once('config.php');
$token = $_POST['stripeToken'];
$customer = \Stripe\Customer::create(array(
'email' => '[email protected]',
'card' => $token
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 25000, //amount in pennies
'currency' => 'gbp'
));
echo 'Successfully charged £250! We will be in touch shortly.';
config.php
require_once('vendor/stripe-php-3.1.0/init.php');
$stripe = array(
"secret_key" => "sk_live_XXXXXXXXXXXX",
"publishable_key" => "pk_live_YYYYYYYYYYYY"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
HTML:
<a class="button price-button one-off-m" href="index.php">£250 /<span class="one-off"></a>
Спасибо, где вы нашли это в документации? :) – Sharan
https://stripe.com/docs/checkout#integration-custom – Kisaragi