gpt4 book ai didi

ruby-on-rails - 通过元数据检索 Stripe Charge

转载 作者:行者123 更新时间:2023-12-04 17:48:09 28 4
gpt4 key购买 nike

我正在尝试使用 Stripe API 收取费用。

一切都很好,但我不明白为什么这个请求不起作用:

Stripe::Charge.all(metadata: { project_id: an_id })

我得到了错误:

Stripe::InvalidRequestError: Received unknown parameter: metadata

响应如下:

{"id":"ch_1BQIXjGrTKCCbjGtKVJOKzbg","object":"charge","amount":1000,"amount_refunded":0,"application":null,"application_fee":"fee_1BQIXlEsrND8ZkheXtsfgQWj","balance_transaction":"txn_1BQIXlGrTKCCbjGtpSDEu34m","captured":true,"created":1511196887,"currency":"eur","customer":"cus_BnuMP3mm0iEFL8","description":"Don","destination":"acct_1BEzwEEsrND8Zkhe","dispute":null,"failure_code":null,"failure_message":null,"fraud_details":{},"invoice":null,"livemode":true,"**metadata":**{"donation_amount":"10","donation_fees":"0","donation_id":"21110","donation_referer_id":"417","donation_reward_id":"2120",**"project_id":"501"**,"project_name":"Arcadia - Le Concert Classique des youtubers","user_city":"Segré","user_country":"FR","user_email":"simon-chretien@hotmail.fr","user_first_name":"Simon","user_id":"23038","user_last_name":"Chrétien"},"on_behalf_of":"acct_1BEzwEEsrND8Zkhe","order":null,"outcome":{"network_status":"approved_by_network","reason":null,"risk_level":"normal","seller_message":"Payment complete.","type":"authorized"},"paid":true,"receipt_email":"simon-chretien@hotmail.fr","receipt_number":"1097-0153","refunded":false,"refunds":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1BQIXjGrTKCCbjGtKVJOKzbg/refunds"},"review":null,"shipping":null,"source":{"id":"card_1BQIXcGrTKCCbjGtKktLMM42","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"FR","customer":"cus_BnuMP3mm0iEFL8","cvc_check":"pass","dynamic_last4":null,"exp_month":10,"exp_year":2020,"fingerprint":"aMPkqWKgq4dQUnWy","funding":"credit","last4":"8073","metadata":{},"name":"simon-chretien@hotmail.fr","tokenization_method":null},"source_transfer":null,"statement_descriptor":null,"status":"succeeded","transfer":"tr_1BQIXlGrTKCCbjGtjFk4oC0D","transfer_group":"group_ch_1BQIXjGrTKCCbjGtKVJOKzbg"},

如您所见,响应中有一个元数据 => project_id

我做错了什么?

最佳答案

正如其中一条评论所说,您可以使用 retrieve如果您想退还一笔费用。您必须将费用 ID 传递给方法:

Stripe::Charge.retrieve('ch_1BQIXjGrTKCCbjGtKVJOKzbg')

您要查找的文档位于 List all charges 下. all 实际上是list 的别名。根据完成您正在做的事情的文档,您可以返回所有 Stripe 费用,然后在 metadata 中搜索 project_id

根据您有多少费用,退回所有费用似乎有些过分。相反,考虑仅根据 customer 返回费用

Only return charges for the customer specified by this customer ID.

Stripe::Charge.list(customer: "cus_BnuMP3mm0iEFL8")
# or
Stripe::Charge.all(customer: "cus_BnuMP3mm0iEFL8")

关于ruby-on-rails - 通过元数据检索 Stripe Charge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47398194/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com