1

早上好,

我正在努力在我的网站上实施 Stripe 以进行付款。除了一个小问题外,一切都在测试中成功:在接受付款时,我没有看到可以转发到我的成功页面的页面。我有一个使用 GET 变量设置的收据页面,但如果 Stripe 检测到元刷新或 PHP 标头转发,它将无法处理。

我用来构建此页面的代码基于此处: http ://code.tutsplus.com/tutorials/so-you-want-to-accept-credit-cards-online--net-25457

有熟悉 Stripe 的人知道我将如何制作收据页面吗?谢谢!

4

2 回答 2

0

成功和失败完全由您的服务器端代码处理。Stripe.js和Stripe Checkout只是生成一个卡片令牌并将其发布到您指定的表单操作。

然后您的工作就是使用该令牌创建费用并显示成功或失败页面。

于 2014-05-09T16:39:48.880 回答
0

要扩展 @colinm ,
您将卡片信息发送到创建令牌并将其返回到表单提交位置的条带。

// Boom! We passed the basic validation, so request a token from Stripe:
Stripe.createToken({
  number: cardNumber,
  cvc: cardCVC,
  exp_month: $('#expiration-month').val(),
  exp_year: $('#expiration-year').val()
}, stripeResponseHandler);

// Prevent the default submit action on the form
return false;

之后,您可以使用令牌进行收费或客户

// Get all the values from the form
$token = $_POST['stripeToken'];
$email = $_POST['email'];
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$price = $_POST['price'];

并且不要忘记在收费/客户之前的某个地方设置 api 密钥!

$trialAPIKey = "your_Secret_testkey";  // These are the SECRET keys!
$liveAPIKey = "your_Secret_Livekey";

Stripe::setApiKey($trialAPIKey);  // Switch to change between live and test environments

在第二种形式之后,您应该让它返回到成功页面(使用 try/catch 循环来处理错误,并在这些之外重定向成功)

于 2016-07-25T15:14:33.137 回答