如何在条带支付网关中生成令牌

rav*_*hah 3 php payment-gateway payment-processing stripe-payments

我想使用Stripe创建支付网关.这是我的代码.配置文件,首先我在confiig文件中添加条带库.我想要一个令牌.如何从条带制作或生成令牌?

<?php
require_once('./lib/Stripe.php');

$stripe = array(
    secret_key      => 'sk_test_SrG9Yb8SrhcDNkqsGdc5eKu1',
    publishable_key => 'pk_test_8ZBVXSwrHDKuQe6dgMNfk8Wl'
);

Stripe::setApiKey($stripe['secret_key']);
?>


<?php require_once('config.php'); ?>

<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount="5000" data-description="One year's subscription"></script>
</form>


<?php require_once('config.php'); ?>

<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount="5000" data-description="One year's subscription"></script>
</form>
Run Code Online (Sandbox Code Playgroud)

rav*_*hah 8

require_once('../lib/Stripe.php');
                Stripe::setApiKey("sk_test_SrG9Yb8SrhcDNkqsGdc5eKu1");

                $result = Stripe_Token::create(
                    array(
                        "card" => array(
                            "name" => $user['name'],
                            "number" => base64decrypt($user['card_number']),
                            "exp_month" => $user['month'],
                            "exp_year" => $user['year'],
                            "cvc" => base64decrypt($user['cvc_number'])
                        )
                    )
                );

                $token = $result['id'];

                $charge = Stripe_Charge::create(array(
                      "amount" => $data_input['amount']*100,
                      "currency" => "usd",
                      "card" => $token,
                      "description" => "Charge for test@example.com" 
                ));
Run Code Online (Sandbox Code Playgroud)