This is just one use-case of Vue Stripe Plugin.
Import and register the StripePlugin
plugin.
This will give you access to this.$stripe
. Using this you can create now create an instance of Stripe Elements.
With this, you can now access the Elements methods like, .create
, .getElement
, and more. See here.
Separate components for each card field.
Official components for these are still in development. So this is just a sample to help you implement them on your own.
Vue Stripe is an easy to implement, and well maintained Vue.js plugin for Stripe Checkout, and Elements.
Easy to implement custom payment elements by Stripe.
ClientSecret is required to render the Payment UI. You first have to generate one by creating a PaymentIntent. See how here.
The ClientSecret looks like this pi_3KIBJd...MLhhr1DIBc5qg_secret_skk...3HIXCXtGjDA
Import the component like so:
Full code example:
For a more comprehensive tutorial, go here https://stripe.com/docs/payments/quickstart
The Card Element lets you collect card information all within one Element.
The Card Element lets you collect card information all within one Element. It includes a dynamically-updating card brand icon as well as inputs for number, expiry, CVC, and postal code. Get started with accepting payment.
Import and register the StripeElementCard
component.
Below is an example of how to use StripeElementCard
to generate a token.
You can access these methods via $refs
, like so this.$refs.elementRef.destroy()
.
Integrate Stripe's collection of high-quality UI components to create payment forms in your Vue.js applications.
Name | Type | Default | Required | Description |
---|---|---|---|---|
Name | Return Type | Description |
---|---|---|
Name | Return Type | Description |
---|---|---|
Name | Type | Default | Required | Description |
---|---|---|---|---|
Name | Return Type | Description |
---|---|---|
Name | Return Type | Description |
---|---|---|
pk
string
none
Stripe's publishable key, you can retrieve this from your Stripe dashboard.
testMode
boolean
false
Add this if you want to bypass the insecure host warning when testing to a non-localhost or non-https links.
Object
none
A set of options to create this Elements instance with.
Object
none
A set of options to confirm a PaymentIntent.
string
none
For usage with Connect only. Specifying a connected account ID (e.g., acct_24BFMpJ1svR5A89k) allows you to perform actions on behalf of that account.
string
none
Override your account's API version.
string
none
A locale used to globally configure localization in Stripe. Setting the locale here will localize error strings for all Stripe.js methods. It will also configure the locale for Elements and Checkout. Default is auto (Stripe detects the locale of the browser).
Note that Checkout supports a slightly different set of locales than Stripe.js.
boolean
false
Disables the advanced fraud detection feature.
submit()
void
Submits the payment
clear()
void
Clears the value(s) of the Element.
destroy()
void
Removes the Element from the DOM and destroys it. A destroyed Element can not be re-activated or re-mounted to the DOM.
focus()
void
Focuses the Element.
unmount()
void
Unmounts the Element from the DOM. Call element.mount to re-attach it to the DOM.
collapse()
void
Collapses the Payment Element into a row of payment method tabs
getElement()
Object
Retrieves a previously created element
update()
void
Updates the element. See official docs for more detail: https://site-admin.stripe.com/docs/js/elements_object/update_payment_element
token
object
Emits the card source or the tokenized version of the user's card
loading
boolean
Emits the current loading state of the component.
error
object
Emits whatever error the component might encounter, especially the ones from Stripe.
element-change
void
The change event is triggered when the Element's value changes. The event payload always contains certain keys, in addition to some Element-specific keys.
element-ready
void
Triggered when the Element is fully rendered and can accept element.focus calls.
element-focus
void
Triggered when the Element gains focus.
element-blur
void
Triggered when the Element loses focus.
element-escape
void
Triggered when the escape key is pressed within an Element.
element-click
void
Triggered when the Element is clicked. This event is only emmited from a paymentRequestButton Element.
pk
string
none
Stripe's publishable key, you can retrieve this from your Stripe dashboard.
testMode
boolean
false
Add this if you want to bypass the insecure host warning when testing to a non-localhost or non-https links.
object
none
A set of options to create this Elements instance with.
object
none
An object containing additional payment information you might have collected. Although these fields are optional, we highly recommend collecting name and address.
boolean
false
Disables the advanced fraud detection feature.
object
none
Set custom class names on the container DOM element when the Stripe element is in a particular state.
object
none
Customize the appearance of this element using CSS properties passed in a Style object.
string
none
A pre-filled set of values to include in the input (e.g., {postalCode: '94110'}
). Note that sensitive card information (card number, CVC, and expiration date) cannot be pre-filled.
boolean
false
Hide the postal code field. Default is false. If you are already collecting a full billing address or postal code elsewhere, set this to true.
string
default
Appearance of the icon in the Element. Either solid or default.
boolean
none
Hides the icon in the Element. Default is false.
boolean
none
Applies a disabled state to the Element such that user input is not accepted. Default is false.
string
none
For usage with Connect only. Specifying a connected account ID (e.g., acct_24BFMpJ1svR5A89k) allows you to perform actions on behalf of that account.
string
none
Override your account's API version.
string
auto
A locale used to globally configure localization in Stripe. Setting the locale here will localize error strings for all Stripe.js methods. It will also configure the locale for Elements and Checkout. Default is auto (Stripe detects the locale of the browser).
Note that Checkout supports a slightly different set of locales than Stripe.js.
blur()
void
Blurs the Element.
clear()
void
Clears the value(s) of the Element.
destroy()
void
Removes the Element from the DOM and destroys it. A destroyed Element can not be re-activated or re-mounted to the DOM.
focus()
void
Focuses the Element.
unmount()
void
Unmounts the Element from the DOM. Call element.mount to re-attach it to the DOM.
void
Updates the options the Element was initialized with. Updates are merged into the existing configuration.
token
object
Emits the card source or the tokenized version of the user's card
loading
boolean
Emits the current loading state of the component.
error
object
Emits whatever error the component might encounter, especially the ones from Stripe.
element-change
void
The change event is triggered when the Element's value changes. The event payload always contains certain keys, in addition to some Element-specific keys.
element-ready
void
Triggered when the Element is fully rendered and can accept element.focus calls.
element-focus
void
Triggered when the Element gains focus.
element-blur
void
Triggered when the Element loses focus.
element-escape
void
Triggered when the escape key is pressed within an Element.
element-click
void
Triggered when the Element is clicked. This event is only emmited from a paymentRequestButton Element.