Stripe Checkout:有没有办法在用户重定向到的“成功”页面中获取名称和电子邮件?

问题描述 投票:0回答:1

使用Stripe Checkout,我有一个按钮,它将用户引导至预制的Stripe Checkout页面。用户填写他们的付款信息,然后提交。付款成功后,它们将被重定向到原始站点上的URL。 (类似于www.example.com/success)。

然后,在他们重定向到的成功页面上,我想编写一个自定义PHP脚本,该脚本在数据库中创建用户,这将使他们可以访问站点的仅成员区域。但是,为了创建该用户,我需要他们在结帐过程中输入的电子邮件地址和名称。

是否有可能从重定向到的成功页面中收集此信息?或换一种说法,Stripe是否会将任何可通过JS或PHP获取的信息发送到成功页面?

php checkout octobercms
1个回答
0
投票

Stripe Checkout模式全部使用javascript,只会创建一个令牌,但是要实际捕获付款,后端需要运行Charge命令。例如:

$charge = \Stripe\Charge::create([
  'amount' => 2000,
  'currency' => 'usd',
  'source' => $token, // token from stripe checkout
  'description' => 'Example charge',
]);

然后,如果要捕获电子邮件和名称,可以执行以下操作:

$name = $charge->billing_details->name
$email = $charge->billing_details->email

这里是收费对象的外观:

{
  "id": "ch_1FoEV02eZvKYlo2CrhIIb3hh",
  "object": "charge",
  "amount": 100,
  "amount_refunded": 0,
  "application": null,
  "application_fee": null,
  "application_fee_amount": null,
  "balance_transaction": "txn_19XJJ02eZvKYlo2ClwuJ1rbA",
  "billing_details": {
    "address": {
      "city": null,
      "country": null,
      "line1": null,
      "line2": null,
      "postal_code": null,
      "state": null
    },
    "email": null,
    "name": null,
    "phone": null
  },
  "captured": false,
  "created": 1576006558,
  "currency": "usd",
  "customer": null,
  "description": "My First Test Charge (created for API docs)",
  "dispute": null,
  "disputed": false,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "on_behalf_of": null,
  "order": null,
  "outcome": null,
  "paid": true,
  "payment_intent": null,
  "payment_method": "card_1FoEUk2eZvKYlo2CH4xOI0A6",
  "payment_method_details": {
    "card": {
      "brand": "visa",
      "checks": {
        "address_line1_check": null,
        "address_postal_code_check": null,
        "cvc_check": null
      },
      "country": "US",
      "exp_month": 8,
      "exp_year": 2020,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "installments": null,
      "last4": "4242",
      "network": "visa",
      "three_d_secure": null,
      "wallet": null
    },
    "type": "card"
  },
  "receipt_email": null,
  "receipt_number": null,
  "receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_1FoEV02eZvKYlo2CrhIIb3hh/rcpt_GKuJm4SIx4vClE2bI43Nq8r6ZvxTtT3",
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [],
    "has_more": false,
    "url": "/v1/charges/ch_1FoEV02eZvKYlo2CrhIIb3hh/refunds"
  },
  "review": null,
  "shipping": null,
  "source_transfer": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "succeeded",
  "transfer_data": null,
  "transfer_group": null
}

在此处了解更多信息:https://stripe.com/docs/api/charges/object

© www.soinside.com 2019 - 2024. All rights reserved.