我有以下代码,它运行时没有错误,但它不会将资金插入到 Stripe 服务器上。Stripe 库已正确安装。
配置文件
<?php
//require_once('vendor/autoload.php');
$stripe = array(
"secret_key" => "sk_test_key",
"publishable_key" => "pk_test_key"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
Run Code Online (Sandbox Code Playgroud)
站点控制器.php
public function actionSend()
{
$model = new SendForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->insertCharge();
//Yii::$app->session->setFlash('Successfully charged $20.00!');
return $this->render('send-confirm', ['model' => $model]);
} else {
return $this->render('send', [
'model' => $model,
]);
}
}// end function
Run Code Online (Sandbox Code Playgroud)
发送.php
<?php $form = ActiveForm::begin(['options' => ['method' => 'post']]); ?>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-name="TEST"
data-description="Testing"
data-amount="2000"
data-locale="auto">
</script>
<?php ActiveForm::end(); ?> …Run Code Online (Sandbox Code Playgroud)