首页 > 解决方案 > 应用程序应存储哪些条带支付费用信息?

问题描述

当集成条带支付(或条带连接)时,条带Stripe::Charge在尝试支付后返回一个对象给应用程序。

存储此信息的最佳实践是什么,即应用程序应在其数据库中存储哪些字段?

我认为至少,应用程序应该存储:

但是对象中还有许多其他字段Stripe::Charge似乎非常重要。但是,存储所有内容可能完全没有必要(矫枉过正)。

Stripe::Charge以下是创建付款意图后返回的对象的示例:

{
  "id": "ch_1HwISYGtUKse83O9n9LJ5DK1",
  "object": "charge",
  "amount": 30000,
  "amount_captured": 30000,
  "amount_refunded": 0,
  "application": null,
  "application_fee": "fee_1HwISY2fgYVxT5fZTsciNPKg",
  "application_fee_amount": 4500,
  "balance_transaction": "txn_1HwISZGtUKse83O9kkrHTynB",
  "billing_details": {"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":"41234","state":null},"email":null,"name":"Ben Johnson","phone":null},
  "calculated_statement_descriptor": "JOE SMITH",
  "captured": true,
  "created": 1607481078,
  "currency": "usd",
  "customer": null,
  "description": null,
  "destination": "acct_1HtSLp2fgYVxT5fZ",
  "dispute": null,
  "disputed": false,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "on_behalf_of": "acct_1HtSLp2fgYVxT5fZ",
  "order": null,
  "outcome": {"network_status":"approved_by_network","reason":null,"risk_level":"normal","risk_score":63,"seller_message":"Payment complete.","type":"authorized"},
  "paid": true,
  "payment_intent": "pi_1HwIQwGtUKse83O9R4k7NiUa",
  "payment_method": "pm_1HwISXGtUKse83O9ua95HqYJ",
  "payment_method_details": {"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":"pass","cvc_check":"pass"},"country":"US","exp_month":12,"exp_year":2034,"fingerprint":"W0rYzPMfZtx74C5u","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_1HYHSFGtUKse83O9/ch_1HwISYGtUKse83O9n9LJ5DK1/rcpt_IXNCchkcmv9fndlQPRCjh4mEtdNtTn0",
  "refunded": false,
  "refunds": {"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1HwISYGtUKse83O9n9LJ5DK1/refunds"},
  "review": null,
  "shipping": null,
  "source": null,
  "source_transfer": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "succeeded",
  "transfer": "tr_1HwISYGtUKse83O9q9ZEE4Gq",
  "transfer_data": {"amount":null,"destination":"acct_1HtSLp2fgYVxT5fZ"},
  "transfer_group": "group_pi_1HwIQwGtUKse83O9R4k7NiUa"
}

所以一个简单实用的问题:在上述信息中,哪些字段应该存储在应用程序的数据库中?

标签: stripe-payments

解决方案


这完全取决于您的应用程序的需求,并且没有通用的答案。您可以存储全部、不存储或选择字段。

当然,id 是一个很好的起点。如果您使用的是客户,您可能还想存储关联的客户 ID。如果您使用目的地费用,您可能希望存储相关帐户。如果您想做一些自定义会计,您可以存储金额和费用。

这取决于。存储任何你喜欢的东西。


推荐阅读