【问题标题】:How to integrate Stripe payment without redirects - Django如何在没有重定向的情况下集成 Stripe 支付 - Django
【发布时间】:2021-05-31 03:06:33
【问题描述】:

我的条带付款已启动并正常工作。但是我希望用户能够在不离开他们所在的页面的情况下进行付款。

是否可以使用 Django 提交 Stripe Payment 而无需重定向?

【问题讨论】:

  • 您能否提供有关您的集成的更多详细信息以及当前存在重定向的原因?这似乎是一个实现细节,因为它不是 Stripe API/客户端的要求。

标签: python django stripe-payments payment-gateway


【解决方案1】:

https://stripe.com/docs/api/metadata

我阅读了文档并认为您可以做到

import stripe
stripe.api_key = "sk_test_123"

stripe.Charge.create(
  amount=2000,
  currency="usd",
  source="tok_amex", # obtained with Stripe.js
  metadata={'order_id': '6735'}
)

{
  "id": "ch_1IQDpm2eZvKYlo2CiLKj2hKU",
  "object": "charge",
  "amount": 100,
  "amount_captured": 0,
  "amount_refunded": 0,
  "application": null,
  "application_fee": null,
  "application_fee_amount": null,
  "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
  "billing_details": {
    "address": {
      "city": null,
      "country": null,
      "line1": null,
      "line2": null,
      "postal_code": null,
      "state": null
    },
    "email": null,
    "name": "Jenny Rosen",
    "phone": null
  },
  "calculated_statement_descriptor": null,
  "captured": false,
  "created": 1614613138,
  "currency": "usd",
  "customer": null,
  "description": "My First Test Charge (created for API docs)",
  "disputed": false,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": null,
  "livemode": false,
  "metadata": {
    "order_id": "6735"
  },
  "on_behalf_of": null,
  "order": null,
  "outcome": null,
  "paid": true,
  "payment_intent": null,
  "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
  "payment_method_details": {
    "card": {
      "brand": "visa",
      "checks": {
        "address_line1_check": null,
        "address_postal_code_check": null,
        "cvc_check": "unchecked"
      },
      "country": "US",
      "exp_month": 12,
      "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_1IQDpm2eZvKYlo2CiLKj2hKU/rcpt_J2IQ7elQ2RfOD61BRlasDqCLV5ErY2f",
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [],
    "has_more": false,
    "url": "/v1/charges/ch_1IQDpm2eZvKYlo2CiLKj2hKU/refunds"
  },
  "review": null,
  "shipping": null,
  "source_transfer": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "succeeded",
  "transfer_data": null,
  "transfer_group": null
}

【讨论】:

    猜你喜欢
    • 2015-01-04
    • 2018-12-17
    • 2017-11-08
    • 1970-01-01
    • 2021-06-13
    • 2023-03-03
    • 1970-01-01
    • 2021-07-03
    • 2021-03-15
    相关资源
    最近更新 更多