payone-gmbh / checkout-demo Goto Github PK
View Code? Open in Web Editor NEWNew to the PAYONE API? Start here!
License: MIT License
New to the PAYONE API? Start here!
License: MIT License
g
d
gf
h
r
j
gh
e
this resolve()
will NOT stop the interval 😉
checkout-demo/js/PayoneCheckout.js
Line 499 in 603c310
ytu
h
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:
<div class="payone-checkout__col">
<label for="cardexpiryyear">Expire year</label>
<section id="cardexpiryyear"></section>
</div>
</div>
<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>
Nothing received yet.
Nothing received yet.
Nothing received yet.
Nothing received yet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.