Retrieving a Braintree customer's subscriptions

会有一股神秘感。 提交于 2019-11-27 15:56:30

问题


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.

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.

Oh, and I'm programming this in rails, but the question doesn't seem Rails-specific.


回答1:


I work at Braintree.

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


来源:https://stackoverflow.com/questions/15910980/retrieving-a-braintree-customers-subscriptions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!