简体   繁体   English

通过javascript api调用(而非节点)获取Stripe客户信息,怎么办?

[英]getting Stripe customer information via javascript api call (not node), how?

I am getting the customer id via the backend, I am also passing the token to the backend.. BUT I have need to display "last4" etc.. on a stored billing page. 我正在通过后端获取客户ID,我还将令牌传递给后端。但是我必须在存储的帐单页面上显示“ last4”等。 How can I achieve that from the client-side only. 我如何只能从客户端实现这一点。 I have the Stripe js api embedded in the page, but I can't locate any method that would allow me to retrieve a users card details (all of them). 我在页面中嵌入了Stripe js api,但是找不到任何允许我检索用户卡详细信息的方法(所有方法)。

When a user creates an account, they are automatically created for a Stripe account. 用户创建帐户时,将自动为Stripe帐户创建他们。 I am returned a stripe_id. 我返回了stripe_id。 With that, how can I generate a stored billing page of the cards they have on "file"? 这样,如何生成他们在“文件”上存储的卡的存储的计费页面?

I see these methods, and outside of "request" - I can't seem to find any docuemntation on these methods and if I can retrieve stored billing details. 我看到了这些方法,并且在“请求”之外-我似乎找不到关于这些方法的任何文档,也无法检索存储的帐单明细。

Object.getOwnPropertyNames(Stripe)
["length", "name", "arguments", "caller", "prototype", "version", "endpoint", "setPublishableKey", "_language", "setLanguage", "_allowedCustomHeaders", "_customHeaders", "_setCustomHeader", "trackPerf", "_isChannel", "_isSafeStripeDomain", "_iframeOnAmount", "_isSafeDomain", "_finalTransport", "_transport", "_fallBackToOldStripeJsTechniques", "_iframePendingRequests", "_iframeChannelStatus", "_iframeChannelComplete", "request", "_rawRequest", "reportError", "_instrumentedRequest", "_getResourceTiming", "_resourceTimingWhitelist", "_sanitizeResourceTiming", "logRUM", "complete", "_iframeBaseUrl", "_stripejsBaseUrl", "_relayResponse", "_callCount", "_callCache", "_receiveChannelRelay", "_channelListener", "token", "card", "bankAccount", "piiData", "_poller", "bitcoinReceiver", "source", "createToken", "getToken", "cardType", "validateExpiry", "validateCVC", "validateCardNumber", "stripejs_ua", "stringify", "parse", "runInContext", "JSON", "easyXDM", "utils", "ajaxJSONP", "xhr", "iframe", "_socket", "validator", "_iframeRequestQueue", "key", "isDoubleLoaded"]

There's no way to do any of this client-side with or without Stripe.js since it would require using your Secret API key. 无论是否使用Stripe.js,都无法进行任何此客户端操作,因为这将需要使用您的Secret API密钥。 You never want to put the Secret API key in the Javascript code as anyone could get access to it otherwise and use it on your behalf. 您永远不要将Secret API密钥放在Javascript代码中,否则任何人都可以访问它并代表您使用它。

What you want to do instead is retrieve the customer server-side in your code first. 相反,您要做的是首先在代码中检索客户服务器端。 Then, you share the data you need (customer id, card's id, last 4 or expiration date) to the client-side code to be able to display the information as needed. 然后,您将所需的数据(客户ID,卡的ID,最后4个或到期日期)共享给客户端代码,以便能够根据需要显示信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM