demetrio812
demetrio812

Reputation: 289

Recurly.js and Angular 4

I'm using an angular reactive form and trying to get a token from Recurly.js.

I've used the recurly suggested name for the input and added the data-recurly="number" for the cc number and so on.

On submit first I call recurly.configure() and then I take the value from the reactive form and pass it to recurly.token() in this way:

recurly.token(this.form.value, function (err, token) {
    if (err) {
      // handle error using err.code and err.fields
      console.log("Recurly token error: " + err);
    } else {
      // handle success using token.id
      console.log("Recurly token success: " + token.id);
    }
  });

this.form.value contains the correct field names and values but I always get the following validation error:

enter image description here

Am I missing something?

Thanks, Dem

Upvotes: 2

Views: 1053

Answers (2)

dbrudner
dbrudner

Reputation: 31

Quick Update

Since the release of Elements, Recurly.js should be compatible with any modern framework, including Vue, Angular, and Electron. A React library is also available.

If anyone comes across this message and is experiencing an issue using Recurly.js with any modern front-end framework, please consider opening an issue with the library.

Upvotes: 3

demetrio812
demetrio812

Reputation: 289

So basically we cannot use reactive forms and recurly support told me they don't support Angular or React (guys, it's 2017!) so we are stuck using their form system that is quite bad if you tell me.

However, in case somebody else needs it, I've created a demo project with a recurly form component that can be easily customised and integrated:

https://github.com/demetrio812/angular-recurly-test

One thing to notice is that multiple forms in the same page aren't supported by Recurly.js library.

Cheers,

Dem

Upvotes: 1

Related Questions