i trying use braintree drop-in ui subscription service on website. how tell server how create subscription?
for instance:
a user has payment method in vault when hit submit server uses payment nonce given create subscription since used vaulted method.
but, if user adds new payment method? how server know create new payment method them since not vaulted , cannot use nonce make new subscription?
really need know how can server know user adding new method versus using 1 vaulted in drop-in ui.
full disclosure: work @ braintree. if have further questions, feel free contact support.
to create subscription using existing payment method, first generate client_token
, passing in customer_id
.
@client_token = braintree::clienttoken.generate( :customer_id => a_customer_id )
after passing client_token
drop-in ui, customer's previous payment methods within form. customer can select 1 of these payment methods, or create new one, , new 1 selected.
after form submission, payment_method_nonce
corresponds selected payment_method sent server. can call subscription.create
, passing in payment_method_nonce
. see our payment_method_nonce
documentation more information.
result = braintree::subscription.create( :payment_method_nonce => "payment_method_nonce", :plan_id => "silver_plan" )
Comments
Post a Comment