Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 检索Braintree客户';s订阅_Ruby On Rails_Ruby_Braintree - Fatal编程技术网

Ruby on rails 检索Braintree客户';s订阅

Ruby on rails 检索Braintree客户';s订阅,ruby-on-rails,ruby,braintree,Ruby On Rails,Ruby,Braintree,我想收集Braintree客户的所有订阅。当我在网关中浏览到客户的页面时,我可以看到他们的订阅,但是对于Braintree::customer,似乎不存在类似subscriptions的方法,或者我可以通过customer\u id搜索Braintree::subscriptions 我可以通过迂回的方式访问客户的所有订阅,但速度非常慢。例如,我可以检索客户的所有交易,对于每个交易,获取订阅id(如果存在),然后使用该id检索订阅。这涉及到与Braintree API的大量通信,我希望找到更有效

我想收集Braintree客户的所有订阅。当我在网关中浏览到客户的页面时,我可以看到他们的订阅,但是对于
Braintree::customer
,似乎不存在类似
subscriptions
的方法,或者我可以通过
customer\u id
搜索
Braintree::subscriptions

我可以通过迂回的方式访问客户的所有订阅,但速度非常慢。例如,我可以检索客户的所有交易,对于每个交易,获取
订阅id
(如果存在),然后使用该id检索订阅。这涉及到与Braintree API的大量通信,我希望找到更有效的解决方案

哦,我正在用rails编程,但这个问题似乎不是rails特有的。

我在Braintree工作

客户有一张信用卡,每张信用卡有一张。因此,如果您想要客户的所有订阅,可以执行以下操作:

customer.credit_cards.map(&:subscriptions).flatten

需要更改哪些内容才能将通过贝宝的订阅考虑在内?@ChristophGeschwind在Ruby中,您可以执行
customer.payment\u methods.map(&:subscriptions)。展平
以获得所有订阅,或者同时使用
customer.credit\u cards
customer.paypal\u帐户
来分别获取它们。是否有一种简单的方法来获取与订阅相关联的客户?所以基本上与OP的要求相反。@SonnyParlin,所以你可以。所以你可以。我将node.js与braintree订阅集成在一起。Braintree提供了良好的文档。然而,它缺乏一个实现订阅的完整流程的指南,我花了一整天才弄明白。因此,我写了一本指南来帮助任何想在这里使用braintree订阅服务的人