Home>
I want to register the card name using payjp.js v2

payjp.js v2 reference
↑ Here

"If i need the name and address of the card, please prepare the form yourself (the information can be passed to the argument of payjp.createToken () and managed)."

"Payjp.createToken (element: Element, options ?: object)"

"Send the name of the e.g. cardholder with {name:'PAY JP'}."

Etc. were described

In the following description (↓ omitted a little)
    let payjp = Payjp ("# {@ api_key}");
    let elements = payjp.elements ();
    let numberElement = elements.create ('cardNumber');
    let expiryElement = elements.create ('cardExpiry');
    let cvcElement = elements.create ('cardCvc');
    numberElement.mount ('# card__form--number-form');
    expiryElement.mount ('# card__form--expiry-form');
    cvcElement.mount ('# card__form--cvc-form');
payjp.createToken (numberElement) .then (function (response) {
  $("# card__form--inputHidden"). Attr ("value", response.id);
  $("# card__form"). submit ();
});
If i add {name:'TARO YAMADA'} as below,
payjp.createToken (numberElement, {name:'TARO YAMADA'}). then (function (response) {
  $("# card__form--inputHidden"). Attr ("value", response.id);
  $("# card__form"). submit ();
});
response.error.message says "There is an invalid parameter for token."
to console
Will result in an error and will not work.
Without, {name:'TARO YAMADA'}, it works fine.
Of course, the name of the card is null, but ...

I would like to register my card name.
I would be grateful if anyone familiar with the matter could teach.

  • Answer # 1

    payjp.createToken (numberElement, {name:'TARO YAMADA'}). then (function (response) {
      $("# card__form--inputHidden"). Attr ("value", response.id);
      $("# card__form"). submit ();
    });


    Not

    payjp.createToken (numberElement, {card: {name:'TARO YAMADA'}}). then (function (response) {
      $("# card__form--inputHidden"). Attr ("value", response.id);
      $("# card__form"). submit ();
    });


    was.

    This is the result of inquiring to payjp.
    It seems that he will correct any mistakes.
    It was a very conscientious and sincere response.
    Thank you ^^

Related articles