javascript - correct way to use Stripe's stripe_account header from oauth with meteor -
i'm trying build platform based on meteor uses stripe connect. want use "preferred" authentication method stripe (authentication via stripe-account header, https://stripe.com/docs/connect/authentication) can create plans , subscribe customers on behalf of users. cannot work. tried second params object, similar exemple in documentation:
var stripeplancreate = meteor.wrapasync(stripe.plans.create, stripe.plans); var plan = stripeplancreate({ amount: prod.price, interval: prod.interv, name: prod.name, currency: prod.curr, id: prod.id+"-"+prod.price+"-"+prod.curr+"-"+prod.interv, metadata: { prodid: prod._id, orgid: org._id }, statement_descriptor: prod.descr },{stripe_account: org.stripe_user_id});
but "exception while invoking method 'createstripeproduct' error: stripe: unknown arguments ([object object]). did mean pass options object? see https://github.com/stripe/stripe-node/wiki/passing-options." not seem accurately reflect issue prompted me try adding stripe_account in params object itself:
var stripeplancreate = meteor.wrapasync(stripe.plans.create, stripe.plans); var plan = stripeplancreate({ amount: prod.price, (...) statement_descriptor: prod.descr, stripe_account: org.stripe_user_id });
i following error: "exception while invoking method 'createstripeproduct' error: received unknown parameter: stripe_account"
any ideas? has managed have stripe connect stripe_account authentication work meteor, meteor.wrapasync(...)?
this should work wrapasync
, check out answer here possible issues wrapasync
- wrapping stripe create customer callbacks in fibers in meteor:
here great video on wrapasync
: https://www.eventedmind.com/feed/meteor-meteor-wrapasync
var createstripeplanasync = function(shoppingcartobject, callback){ stripe.plans.create({ amount: shoppingcartobject.plan.totalprice, interval: shoppingcartobject.plan.interval, name: shoppingcartobject.plan.planname, currency: "usd", id: shoppingcartobject.plan.sku //this id needs unique! }, function(err, plan) { // asynchronously called callback(err, plan); }); }; var createstripeplansync = meteor.wrapasync(createstripeplanasync); var myshoppingcart = { customerinfo: { name: "igor trout" }, plan: { totalprice: 5000, interval: "month", name: "set sail fail plan", sku: "062015ssff" } }; // creates plan in stripe account createstripeplansync(myshoppingcart);
later when subscribe customer plan refer plan via id
gave plan when first created it.
Comments
Post a Comment