【问题标题】:Stripe: Confirmation Page条纹:确认页面
【发布时间】:2014-05-05 13:07:13
【问题描述】:

早上好,

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

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

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

【问题讨论】:

标签: php stripe-payments stripe.net


【解决方案1】:

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

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

【讨论】:

  • 生成token后付款还是生成token支付成功??
【解决方案2】:

扩展 @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 循环来处理错误,并在这些之外使用重定向来获得成功)

【讨论】:

    猜你喜欢
    • 2017-02-05
    • 2020-09-12
    • 2017-11-28
    • 1970-01-01
    • 2014-03-25
    • 1970-01-01
    • 2016-06-07
    • 2010-12-26
    • 2013-01-28
    相关资源
    最近更新 更多