Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isCardTypeComplete = False & isCvcComplete = False #14

Open
ck88ger opened this issue May 17, 2023 · 1 comment
Open

isCardTypeComplete = False & isCvcComplete = False #14

ck88ger opened this issue May 17, 2023 · 1 comment

Comments

@ck88ger
Copy link

ck88ger commented May 17, 2023

Hi,

ich see your checkout demo with the iframe solution and it works well if i start your project. If i adapt this to my own project i get this two values as FALSE so the check can not perform.

This is my Code:

TS FILE:
`

export class HomeComponent implements AfterViewInit {

iframes: any;

_creditCardCheckResponse: any;

_supportedCardTypes: string[];

constructor() {
this._supportedCardTypes = ['V', 'M']
}

ngAfterViewInit() {
this.initPayone();
}

initPayone() {

const supportedCardtypes = ["V", "M"];
const config = {
  fields: {
    cardpan: {
      selector: "cardpan",
      style: "font-size: 14px; border: 1px solid #000;",
      type: "input"
    },
    cardcvc2: {
      selector: "cvc",
      type: "password",  // Could be "text" as well.
      style: "font-size: 14px; border: 1px solid #000;",
      size: "4",
      maxlength: "4",
      length: { "V": 3, "M": 3 } // enforce 3 digit CVC für VISA and Mastercard
    },
    cardexpiremonth: {
      selector: "cardexpirymonth",
      type: "text", // select (default), text, <span class="sp-highlight-term underline sp-cursor-pointer" style="background-color: rgb(255, 255, 255);">tel</span>
      size: "2",
      maxlength: "2",
      iframe: {
        width: "40px"
      },
      style: "font-size: 14px; width: 30px; border: solid 1px #000; height: 22px;"
    },
    cardexpireyear: {
      selector: "cardexpiryyear",
      type: "text", // select (default), text, <span class="sp-highlight-term underline sp-cursor-pointer" style="background-color: rgb(255, 255, 255);">tel</span>
      iframe: {
        width: "60px"
      },
      style: "font-size: 14px; width: 50px; border: solid 1px #000; height: 22px;"
    }
  },
  defaultStyle: {
    input: "font-size: 1em; border: 1px solid #000; width: 175px;",
    select: "font-size: 1em; border: 1px solid #000;",
    iframe: {
      height: "22px",
      width: "180px"
    }
  },

  autoCardtypeDetection: {
    supportedCardtypes: supportedCardtypes,
    callback: (detectedCardtype: any) => {

      // For the output container below.
      // @ts-ignore
      document.getElementById('autodetectionResponsePre').innerHTML = detectedCardtype;

      if (detectedCardtype === 'V') {
        // @ts-ignore
        document.getElementById('visa').style.borderColor = '#00F';
        // @ts-ignore
        document.getElementById('mastercard').style.borderColor = '#FFF';
      } else if (detectedCardtype === 'M') {
        // @ts-ignore
        document.getElementById('visa').style.borderColor = '#FFF';
        // @ts-ignore
        document.getElementById('mastercard').style.borderColor = '#00F';
      } else {
        // @ts-ignore
        document.getElementById('visa').style.borderColor = '#FFF';
        // @ts-ignore
        document.getElementById('mastercard').style.borderColor = '#FFF';
      }
    } //,
    // deactivate: true // To turn off automatic card type detection.
  },

  language: 'de', //, // Language to display error-messages (default: Payone.ClientApi.Language.en)
  error: "error" // area to display error-messages (optional)
};

const request = {
  'mid': ID,
  'portalid': ID,
  'aid': ID,
  'hash': this.generateJsHash(),
  'mode': 'test',
  'responsetype': 'JSON',
  'encoding': 'UTF-8',
  'request': 'creditcardcheck',
  'storecarddata': 'yes'
};



this.iframes = new Payone.ClientApi.HostedIFrames(config, request);

const cardTypesLine = document.querySelector('#checkoutCardTypesLine')
// @ts-ignore
cardTypesLine.innerHTML = this._supportedCardTypes.reduce((acc, type) => (
  acc + `<img class="payone-checkout__card ${type === 'V' ? 'payone-checkout__card-visa' : ''}" data-card-type="${type}" src="https://cdn.pay1.de/cc/${type.toLowerCase()}/s/transparent.png" alt="${type} card icon">`
), '')

}

onSubmit() {
console.log("isCardTypeComplete", this.iframes.isCardTypeComplete());
console.log("isCardpanComplete", this.iframes.isCardpanComplete());
console.log("isCvcComplete", this.iframes.isCvcComplete());
console.log("isExpireMonthComplete", this.iframes.isExpireMonthComplete());
console.log("isExpireYearComplete", this.iframes.isExpireYearComplete());
console.log("check", this.iframes.isComplete());
if (this.iframes.isComplete()) {
// Perform "CreditCardCheck" to create and get a PseudoCardPan; then call your function "payCallback"
this.iframes.creditCardCheck('payCallback');
} else {
alert("Not complete. Nothing done.");
}

}

payCallback(response:any) {

console.debug(response);

}

public generateJsHash(): string
{
// logic to generate hash
}

}
`

My Html:

Card number
Expire month
  <div class="payone-checkout__col">
    <label for="cardexpiryyear">Expire year</label>
    <section id="cardexpiryyear"></section>
  </div>
</div>
CVC
  <div class="payone-checkout__col">
    <label for="country">Country</label>
    <select name="country" id="country">
      <option value="DE">Germany</option>
      <option value="GB">United Kingdom</option>
    </select>
  </div>
</div>
Surname
Submit

The JSON received from the server

Nothing received yet.

Autodetection callback result

Nothing received yet.

The JSON received from the server

Nothing received yet.

Autodetection callback result

Nothing received yet.
Bildschirm­foto 2023-05-17 um 13 35 08
@ck88ger
Copy link
Author

ck88ger commented May 17, 2023

Solved it, the Cardtype field was missing... In your checkout example it was not included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant