Reputation: 11807
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. 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).
When a user creates an account, they are automatically created for a Stripe account. I am returned a 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"]
Upvotes: 0
Views: 762
Reputation: 25552
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. 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.
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.
Upvotes: 1