stripe-payments - 应用程序应存储哪些条带支付费用信息?
问题描述
当集成条带支付(或条带连接)时,条带Stripe::Charge
在尝试支付后返回一个对象给应用程序。
存储此信息的最佳实践是什么,即应用程序应在其数据库中存储哪些字段?
我认为至少,应用程序应该存储:
- 付款的
id
(以便将来可以查找), - 付款的
status
(因此应用程序可以知道付款是否通过) - 该应用程序显然应该记录付款对应的购买
但是对象中还有许多其他字段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"
}
所以一个简单实用的问题:在上述信息中,哪些字段应该存储在应用程序的数据库中?
解决方案
这完全取决于您的应用程序的需求,并且没有通用的答案。您可以存储全部、不存储或选择字段。
当然,id 是一个很好的起点。如果您使用的是客户,您可能还想存储关联的客户 ID。如果您使用目的地费用,您可能希望存储相关帐户。如果您想做一些自定义会计,您可以存储金额和费用。
这取决于。存储任何你喜欢的东西。
推荐阅读
- go - 测试脚本不会
- mysql - 选择部分的第一个和最后一个时间戳
- javascript - javascript中的最大调用堆栈大小超出错误
- python-3.x - 使用 Python 连接到 AWS Postgres 数据库:连接被拒绝错误
- arrays - 如何打印唯一元素的数量而不是在我的代码中显示元素本身?
- vue.js - 如何在 Vue 的文件夹中构建页面?
- java - 为什么我必须使用 @JoinColumn 而不是 @Column
- javascript - 条纹元素 - 苹果支付问题 - 支付窗口出现并在一秒钟内消失
- command - bot 响应特定频道 discord.js
- python - 从段落中提取整数