Skip to content

Instantly share code, notes, and snippets.

@mat-twg
Last active October 12, 2023 17:02
Show Gist options
  • Save mat-twg/481b3f7bfe896eb7be934f34aefed76f to your computer and use it in GitHub Desktop.
Save mat-twg/481b3f7bfe896eb7be934f34aefed76f to your computer and use it in GitHub Desktop.
Yookassa payment_token example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Получение `payment_token`</title>
<script src='https://static.yoomoney.ru/checkout-js/v1/checkout.js'></script>
</head>
<body>
<p>Данные банковской карты для оплаты в <b>тестовом магазине</b>:</p>
<ul>
<li>номер — <b>5555 5555 5555 4477</b></li>
<li>срок действия — <b>01/30</b> (или другая дата, больше текущей)</li>
<li>CVC — <b>123</b> (или три любые цифры)</li>
<li>код для прохождения 3-D Secure — <b>123</b> (или три любые цифры)</li>
</ul>
<p><b>payment_token</b>:</p>
<div class='payment_token' style='word-wrap: break-word'></div>
<script>
const checkout = YooMoneyCheckout('266276', {
language: 'en',
});
checkout.tokenize({
number: '5555555555554444',
cvc: '112',
month: '02',
year: '34',
}).then(res => {
if (res.status === 'success') {
const {paymentToken} = res.data.response;
return document.querySelector('.payment_token').append(paymentToken);
}
document.querySelector('.payment_token').append('failure');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment