0👍
There is no need to create both a payment method and a token. The PaymentMethods API can be thought of as a newer version of the Tokens API (1). So you can simplify your code to:
methods : {
pay() {
createPaymentMethod('card', {
billing_details: {
name: this.name, // cardholder name
email: this.email,
address: { // address fetched from algolia places
line1: this.street,
country: this.selectedCountry,
city: this.city,
postal_code: this.postalCode,
},
}
})
}
}
*Note, I removed the card: data.token.card.id
line entirely. This should be unnecessary since the library you’re using adds a reference to the Card element for you automatically as you can see here:
Source:stackexchange.com