【发布时间】:2016-06-27 05:00:48
【问题描述】:
所以我希望向客户(非用户)收取与条形表单中显示的金额相同的金额
<form action="/charge" method="POST">
{!! csrf_field() !!}
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_key"
data-amount="{{ $note->price*100 }}"
data-name="Hello World"
data-description="{{$note->title}}"
data-image="/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-currency="aud">
</script>
</form>
在表格中显示的价格是相关钞票型号中列出的价格 * 100。我希望客户实际支付这个值,它会根据钞票而变化。
这是我的服务器帐单
public function charge()
{
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_key");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => 100, // amount in cents, again
"currency" => "aud",
"source" => $token,
"description" => "Example charge"
));
} catch(\Stripe\Error\Card $e) {
// The card has been declined
}
return 'payment succesful';
}
我需要将“金额”设置为等于票据价值。
否则,付款将通过我的收银员测试帐户进行,并且大多数情况下其他一切都需要正常工作。
但客户不是注册用户。
【问题讨论】:
标签: php laravel stripe-payments laravel-cashier