そのため、ストライプ形式で表示されている金額と同じ金額を顧客 (ユーザーではない) に請求したい
<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';
}
「量」を音価に等しく設定する必要があります。
それ以外の場合は、レジのテスト アカウントで支払いが行われており、他のほとんどすべてが機能している必要があります。
ただし、顧客は登録ユーザーではありません。