在看似无休止地了解Braintree的混淆文档的过程中,我最终创建了自己的更新UI,其列表为BTPaymentMethod
Braintree文档说要使用令牌更新付款方式(我在我的在线沙盒库中看到)。如何检索要更新的单个客户卡令牌?
我使用-[BTClient fetchPaymentMethodsWithSuccess:failure:]
,它返回BTPaymentMethod
只有payment_nonce
属性的CVV is required.
。尝试使用此属性进行更新会返回错误def update_payment_default
@customer = Customer.where(id: params[:id]).first
if @customer.present?
@string = "customer_" + @customer.id.to_s
result = Braintree::Customer.update(
"my_customer_id"
:credit_card => {
:payment_method_nonce => params[:payment_method_nonce],
:options => {
:make_default => true
}
}
)
if result.success?
respond_to do |format|
msg = {:status => "SUCCESS", :message => "Updated payment payment method"}
format.json { render :json => msg } # don't do msg.to_json
end
else
respond_to do |format|
msg = {:status => "FAILED", :message => result.errors}
format.json { render :json => msg } # don't do msg.to_json
end
end
end
{{1}}