检索Braintree客户的订阅 [英] Retrieving a Braintree customer's subscriptions
问题描述
我想收集所有Braintree客户的订阅。当我浏览到网关中的客户页面时,我可以看到他们的订阅,但是对于 Braintree,似乎不存在像
,或者我可以通过 subscriptions
这样的方法。 :: Customer customer_id
搜索 Braintree :: Subscriptions
。
I want to collect all of a Braintree Customer's subscriptions. When I browse to a customer's page in the gateway, I can see their subscriptions, but it doesn't seem that a method like subscriptions
exists for Braintree::Customer
, or that I can search for Braintree::Subscriptions
by customer_id
.
我可以通过多种方式访问客户的所有订阅,但它们的速度非常慢。例如,我可以检索所有客户的交易,对于每个交易,获取 subscription_id
(如果存在),然后检索具有该ID的订阅。
There are roundabout ways that I can access all of a customer's subscriptions, but they are very slow. For example, I can retrieve all of the customer's transactions, and for each transaction, get the subscription_id
(if it exists), and then retrieve the subscription with that ID. This involves a lot of communication with the Braintree API, and I was hoping for a more efficient solution.
哦,我正在用rails编程,但是问题是
Oh, and I'm programming this in rails, but the question doesn't seem Rails-specific.
推荐答案
我在Braintree工作。
客户拥有 credit_cards
数组,并且每张信用卡都有一个 订阅
数组。因此,如果要为客户提供所有订阅,则可以执行以下操作:
Customers have a credit_cards
array, and each credit card has a subscriptions
array. So, if you want all the subscriptions for a customer, you can do:
customer.credit_cards.map(&:subscriptions).flatten
这篇关于检索Braintree客户的订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!