如何从 Braintree Webhooks 获取交易(SubscriptionChargedSuccessfuly)?
How to get transaction from Braintree Webhooks (SubscriptionChargedSuccessfuly)?
我想在客户的订阅收费时发送发票。发票包括交易的详细信息(产品信息和价格等)。如何从 WebhookNotification 中找到交易?
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系我们的 support 团队。
订阅 webhooks 有 subscription attribute. Subscriptions have a transactions attribute.
为了访问最近的交易,您可以执行如下操作:
post "/webhooks" do
webhook_notification = Braintree::WebhookNotification.parse(
request.params["bt_signature"],
request.params["bt_payload"]
)
puts "Most recent transaction: #{webhook_notification.subscription.transactions[0]}"
return 200
end
webhook_notification.subscription.transactions.first
将获得与该订阅相关的第一笔(最近的)交易。
我想在客户的订阅收费时发送发票。发票包括交易的详细信息(产品信息和价格等)。如何从 WebhookNotification 中找到交易?
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系我们的 support 团队。
订阅 webhooks 有 subscription attribute. Subscriptions have a transactions attribute.
为了访问最近的交易,您可以执行如下操作:
post "/webhooks" do
webhook_notification = Braintree::WebhookNotification.parse(
request.params["bt_signature"],
request.params["bt_payload"]
)
puts "Most recent transaction: #{webhook_notification.subscription.transactions[0]}"
return 200
end
webhook_notification.subscription.transactions.first
将获得与该订阅相关的第一笔(最近的)交易。