Giter Site home page Giter Site logo

checkout-demo's People

Contributors

alexdz27 avatar hreinberger avatar janteuber avatar

Stargazers

 avatar  avatar

Watchers

 avatar

checkout-demo's Issues

h

gh

isCardTypeComplete = False & isCvcComplete = False

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.