Skip to content

Commit 5a9a931

Browse files
authored
Use a separate container for the result message (#65)
1 parent 9363b5c commit 5a9a931

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

standard-integration/index.html

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
</head>
88
<body>
99
<div id="paypal-button-container"></div>
10+
<p id="result-message"></p>
1011
<!-- Replace the "test" client-id value with your client-id -->
1112
<script src="https://www.paypal.com/sdk/js?client-id=test&currency=USD"></script>
1213
<script>
1314
paypal
1415
.Buttons({
15-
createOrder: async (data) => {
16+
createOrder: async () => {
1617
try {
1718
const response = await fetch('/api/orders', {
1819
method: 'POST',
@@ -88,7 +89,7 @@
8889
const transaction =
8990
orderData.purchase_units[0].payments.captures[0];
9091
resultMessage(
91-
`<h3>Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details</h3>`,
92+
`Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`,
9293
);
9394
console.log(
9495
'Capture result',
@@ -107,12 +108,10 @@
107108
.render('#paypal-button-container');
108109

109110
// Example function to show a result to the user. Your site's UI library can be used instead,
110-
// however alert() should not be used as it will interrupt the JS SDK window
111+
// however alert() should not be used as it will interrupt the JS SDK popup window
111112
function resultMessage(message) {
112-
const container = document.getElementById('paypal-button-container');
113-
const p = document.createElement('p');
114-
p.innerHTML = message;
115-
container.parentNode.appendChild(p);
113+
const container = document.getElementById('result-message');
114+
container.innerHTML = message;
116115
}
117116
</script>
118117
</body>

0 commit comments

Comments
 (0)