Я пытаюсь использовать createSource
в Stripe, и для этого я использую обещание в клиенте примерно так:
function prepare(name, email, phone){
stripe.createSource({
type: 'oxxo',
amount: <?= $price ?>,
currency: 'mxn',
owner: {
name: name,
email: email,
phone: phone,
},
}).then(function(result) {
handle(result);
}).catch(function(err){
console.log("Error!");
console.error(err);
});
}
это вызывает handle()
, который выглядит так:
function handle(source){
console.log(source); // returns the object in img below
receiverInfo.innerHTML = `<img width="150px" src="/assets/img/oxxo.png"></img><svg id="barcode"></svg>`;
JsBarcode("#barcode", source.oxxo.number, {
text: source.oxxo.number.match(/.{1,4}/g).join (" "),
width: 2,
height: 50,
fontSize: 15,
});
}
Однако при этом я получаю: Uncaught TypeError: Cannot read property 'number' of undefined
несмотря на то, что вижу значение в консоли:
Что мне здесь не хватает?