Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving a Braintree customer's 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.

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.

like image 561
bissej Avatar asked Apr 09 '13 19:04

bissej


People also ask

Does Braintree support recurring payments?

With Braintree's recurring billing, you can charge your customers automatically in monthly increments. In order to set this up, you'll need to create a plan in the Control Panel or via the API and store your customers in the Vault.

What is the difference between Braintree and PayPal?

Braintree is aimed at higher-volume eCommerce businesses that need a lot of custom control over their payment processes. In contrast, PayPal is designed to be simple and easy to use for merchants with modest eCommerce needs.

What is Braintree subscription?

Braintree is an outstanding payment processor and payment gateway that offers businesses/vendors a dedicated merchant account, and support to the third-party merchant account.

Does PayPal own Braintree?

Braintree was acquired by PayPal in 2013, and it's hands-down the more tech-forward PSP among the two. With its suite of developer tools, you or your engineers can customize your shopping cart and integrate it with your existing platform.


1 Answers

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
like image 180
agf Avatar answered Oct 06 '22 00:10

agf