我在Rails应用程序中使用Braintree支付网关。我想知道我是否可以从中检索客户的订阅详情。根据文档,其中一种方法是subscription = Braintree::Subscription.find(id)
创建订阅时,plan_id
和amount
等基本对象已保存到数据库中。那么,如何检索订阅的信息,例如与客户关联的next_billing_date
?
答案 0 :(得分:1)
# Find the subscription
subscription = Braintree::Subscription.find(sub_id)
# Access the subscription's next billing date
subscription.next_billing_date
Braintree::Subscription.find()
返回Braintree::Subscription
result object。
# Find the customer
customer = Braintree::Customer.find(cust_id)
# Retrieve the customer's first payment method
pm = customer.payment_methods.first
# Retrieve the subscriptions created with that payment method
subscriptions = pm.subscriptions
# Access the subscription's next billing date
subscriptions.first.next_billing_date
Braintree::Customer.find()
返回Braintree::Customer
response object。客户的payment methods can then be retrieved。订阅与付款方式相关联。获得付款方式后,您可以检索an array of Braintree::Subscription
objects。