@payfurl/vue-plugin
v1.5.0
Published
PayFURL Vue Plugin
Readme
@payfurl/vue-plugin
The payFURL drop-in for Vue 3. PayfurlDropin renders payFURL's payment form: cards, Google Pay, Apple
Pay, PayPal, PayTo and the other payment methods your payFURL account offers. It collects the payment
details without them touching your servers. It wraps the payFURL Client SDK
(@payfurl/client), which it includes.
Full guide: Vue on docs.payfurl.com.
Install
npm install @payfurl/vue-pluginVue 3 is a peer dependency.
Use
<script setup lang="ts">
import { PayfurlDropin, type SuccessResponseType, type FailureResponseType } from "@payfurl/vue-plugin";
const onSuccess = (message: SuccessResponseType) => console.log("token", message.token);
const onFailure = (message: FailureResponseType) => console.error(message.error);
const onLoaded = () => console.log("drop-in ready");
</script>
<template>
<PayfurlDropin
environment="sandbox"
public-key="<your public key>"
:amount="20"
currency="AUD"
@onSuccess="onSuccess"
@onFailure="onFailure"
@onLoaded="onLoaded"
/>
</template>Send the token from @onSuccess to your server and charge it with payFURL's API.
Props
| Prop | Type | |
|---|---|---|
| environment | "sandbox" or "production" | Required |
| publicKey | string | Required. Your account's public key |
| amount | number | Required. In the currency's major unit (20 is $20.00) |
| currency | string | Required. A 3-letter ISO 4217 code, e.g. "AUD" |
| options | DropInOptionsType | Optional. See Drop In UI options |
| debug | boolean | Optional. Logs the SDK's activity to the browser console |
| successMessage | string | Optional. Shown when the payment details are collected |
| customer | CustomerInfoType | Optional, 1.5.0+. The shopper: name, email, phone. See Customer and order details |
| billingAddress | AddressInfoType | Optional, 1.5.0+. The shopper's billing address |
| order | OrderInfoType | Optional, 1.5.0+. The order: items, tax, shipping, discount |
| onValidate | () => boolean | Optional. Return false to stop the submission, e.g. while your terms checkbox is unchecked |
3D Secure, fraud checks, Click to Pay and checkout providers use customer, billingAddress and order, so pass
what you know.
Changing props
amount,successMessage,customer,billingAddress,order: a new value updates the drop-in in place, and the shopper keeps what they typed. To change the amount on the fly, change theamountprop: the component calls the SDK'ssetAmount()for you.currency,options: a new value rebuilds the drop-in. PayPal loads its buttons for one currency.environment,publicKey,debug: read once, when the component mounts. The SDK runs one instance per page, so switching account or environment takes a page reload.- Objects are compared by value: a new object with the same values changes nothing.
- Event listeners and
onValidate: the current ones are used when they fire.
Don't call setAmount() (or any other SDK method) on your own import payfurl from "@payfurl/client": this
package includes its own copy of the SDK, so the call doesn't reach the drop-in. Change the props instead.
Events
| Event | Payload | |
|---|---|---|
| @onSuccess | SuccessResponseType | Essential. The payment details were collected: token, or transactionId for payment methods that complete the payment themselves. Without a listener, the SDK puts the token in a hidden token input and submits the <form> around the component; with neither, the details reach nobody and the console warns |
| @onFailure | FailureResponseType | error, and errorDetails when the provider declined |
| @onLoaded | none | The form, or a payment method's button, is ready |
| @onValidationStatusChange | status: string, message: string | The card form's validation changed |
| @onPaymentMethodStatus | PaymentMethodStatusType | 1.5.0+. A payment method's button rendered, or won't and why. See Payment method status handler |
| @onThreeDsProgress | ThreeDsProgressType | 1.5.0+. 3-D Secure started, showed a challenge, completed. See 3-D Secure progress handler |
Each event's payload is typed in the package's type definitions, so your editor shows it.
Types
The package re-exports the SDK's types: DropInOptionsType, UpiOptionsType, DropInGooglePayOptionsType,
DropInApplePayOptionsType, ClickToPayOptionsType, NetworkTokenOptionsType, SuccessResponseType,
FailureResponseType, PaymentMethodStatusType, ThreeDsProgressType, CustomerInfoType, AddressInfoType
and OrderInfoType.
Support
Documentation · SDK changelog · Support
Changelog
What changed in each version of @payfurl/vue-plugin. Changes to the payment form itself are in the
Client SDK changelog. This changelog starts with version 1.4.0.
1.5.0
Added
@onPaymentMethodStatusand@onThreeDsProgressevents: a payment method's button rendered or won't render and why, and 3-D Secure's progress (started, challenge shown, completed).customer,billingAddressandorderprops: the shopper and the order, which 3-D Secure, fraud checks, Click to Pay and checkout providers use. Before, the drop-in had no way to receive them. A change, even inside the object, updates the drop-in in place.- The
PaymentMethodStatusType,ThreeDsProgressType,CustomerInfoType,AddressInfoTypeandOrderInfoTypetypes.
Changed
- Without an
@onSuccesslistener, the SDK now puts the token in a hiddentokeninput and submits the<form>around the component, as it does without a success handler outside Vue. Before, the token reached nothing. With neither a listener nor a form, the console warns. - A new
currencyoroptionsrebuilds the drop-in, as in the React plugin, so PayPal shows the new currency. Before, the currency changed in place, with PayPal still on the old one, and newoptionswere ignored. - The current
onValidateis asked at submit, not the one passed at mount. - Every event's payload is typed in the package's type definitions.
- Depends on
@payfurl/client4.11.0 or later, which adds these handlers.
1.4.0
Added
- TypeScript types for every prop, from
@payfurl/client, and the package's own type definitions now load.
