1
我有一個簡單的自定義按鈕條紋結帳安裝在收費付款好的時刻,但我似乎無法讓客戶的電子郵件地址傳回給條紋。爲什麼客戶的電子郵件地址不發送給Stripe?
繼承人我當前的代碼:
JS
var handler = StripeCheckout.configure({
key: 'myPublicKey',
image: '/images/RoadPreview.jpg',
locale: 'auto',
token: function(token, args){
$form.append(jQuery('<input type="hidden" name="stripeToken" />').val(token.id));
$form.append(jQuery('<input type="hidden" name="stripeEmail" />').val(token.email));
$form.get(0).submit();
}
});
jQuery('#roadFlow').on('click', function(e) {
var token = function(res){
var $input = jQuery('<input type=hidden name=stripeToken />').val(res.id);
jQuery('form').append($input).submit();
};
// Open Checkout with further options
handler.open({
name: 'Road Bike - Flow',
description: 'Make a £500 deposit to Order Now',
billingAddress: true,
shippingAddress: true,
currency: "gbp",
amount: 50000,
token: token
});
e.preventDefault();
});
jQuery(window).on('popstate', function() {
handler.close();
});
PHP
<?php
require_once('stripeConfig.php');
\Stripe\Stripe::setApiKey("mySecretKey");
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$customer = \Stripe\Customer::create(array(
'id' => $name,
'email' => $email,
'card' => $token
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 50000,
'description' => "Dassi Road - Flow",
"receipt_email" => $email,
'currency' => 'gbp'
));
echo '<h1>Successfully Paid!</h1>';
?>
按鈕
<form action="charge.php" method="post"><button type="submit" id="roadFlow">Order Now</button>
任何想法,我要去哪裏錯了?
不清楚這一步是問題,或者你如何讓電子郵件發送給條紋創建令牌 – charlietfl