從Transaction.sale()
或Subscription.create()
的result
中,如何訪問付款中的信用卡詳細信息?Braintree-如何從交易或訂閱中獲取last_4信用卡信息
我有以下幾種方法:
def bt_make_customer(donation, nonce)
result = Braintree::Customer.create(
first_name: donation.user.first_name,
last_name: donation.user.last_name,
email: donation.user.email,
payment_method_nonce: nonce
)
end
def bt_make_payment(donation, customer, nonce)
if donation.type == "ReoccurringDonation"
result = Braintree::Subscription.create(
payment_method_token: customer.payment_methods[0].token,
price: donation.amount,
plan_id: "pay-monthly"
)
elsif donation.type == "SingleDonation"
result = Braintree::Transaction.sale(
:amount => donation.amount,
:payment_method_nonce => nonce,
:options => {:submit_for_settlement => true}
)
end
end
正如你可以看到,該程序接受一次性的捐贈,或每月訂閱。無論何時完成,我都希望獲取諸如last_4之類的信用卡詳細信息以顯示在自定義收據中。
我得到了'NoMethodError異常:未定義的方法'last_4'爲# –
Mirror318