Skip to content

Commit d5a4e35

Browse files
committed
better paypal error message
1 parent 4606da9 commit d5a4e35

5 files changed

Lines changed: 45 additions & 3 deletions

File tree

Synergism.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,3 +5746,20 @@ html[data-golden-quark3-upg="false"] .goldenQuark3Upg {
57465746
pointer-events: all;
57475747
display: none;
57485748
}
5749+
5750+
@keyframes rainbow-border {
5751+
0% { border-color: #f00; }
5752+
16.67% { border-color: #ff7f00; }
5753+
33.33% { border-color: #ff0; }
5754+
50% { border-color: #0f0; }
5755+
66.67% { border-color: #00f; }
5756+
83.33% { border-color: #8b00ff; }
5757+
100% { border-color: #f00; }
5758+
}
5759+
5760+
.rainbow-border-highlight {
5761+
border: 3px solid #f00;
5762+
border-radius: 5px;
5763+
padding: 5px;
5764+
animation: rainbow-border 2s linear infinite;
5765+
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4542,7 +4542,7 @@ <h1 id="pCoinUpgradeName">Welcome to the PseudoShop!</h1>
45424542

45434543
<p id="totalCost"></p>
45444544

4545-
<section style="display:flex;margin:0 auto">
4545+
<section id="tosSection" style="display:flex;margin:0 auto">
45464546
<input type="radio" id="tosAgree" name="tosAgree" style="margin-right:2px">
45474547
<label for="tosAgree">
45484548
I agree to the <a href="https://synergism.cc/terms-of-service" style="color:cyan">Terms of Service</a>

src/Utility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export const findInsertionIndex = (target: number, array: number[]): number => {
304304
/**
305305
* @license {MIT}
306306
* https://github.com/nodejs/undici/blob/6301265a20868d077faae6d51f5f6cf57ac2ebfe/lib/web/infra/index.js#L121
307-
*
307+
*
308308
* I'm stealing my own code, fuck off
309309
*/
310310
export function isomorphicDecode (input: Uint8Array) {

src/mock/handlers/PaymentHandlers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,8 @@ export const paymentHandlers: HttpHandler[] = [
113113
'features': []
114114
}
115115
])
116+
}),
117+
http.post('https://synergism.cc/paypal/orders/create', () => {
118+
return HttpResponse.json({ error: 'You did not agree to the TOS.' })
116119
})
117120
]

src/purchases/CheckoutTab.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const form = tab.querySelector('div.cartList')!
1212

1313
const checkoutStripe = form.querySelector<HTMLElement>('button#checkout')
1414
const checkoutNowPayments = form.querySelector<HTMLElement>('button#checkout-nowpayments')
15+
const tosSection = form.querySelector('section#tosSection')!
1516
const radioTOSAgree = form.querySelector<HTMLInputElement>('section > input[type="radio"]')!
1617
const totalCost = form.querySelector('p#totalCost')
1718
const itemList = form.querySelector('#itemList')!
@@ -99,6 +100,11 @@ export const initializeCheckoutTab = memoize(() => {
99100
checkoutStripe?.addEventListener('click', submitCheckout)
100101
checkoutNowPayments?.addEventListener('click', submitCheckout)
101102

103+
// Remove rainbow border highlight when TOS is clicked
104+
radioTOSAgree.addEventListener('change', () => {
105+
tosSection.classList.remove('rainbow-border-highlight')
106+
})
107+
102108
initializePayPal_OneTime('#checkout-paypal')
103109
})
104110

@@ -272,14 +278,30 @@ async function initializePayPal_OneTime (selector: string | HTMLElement) {
272278
},
273279

274280
onError (error) {
281+
if (error instanceof Error) {
282+
try {
283+
const message = JSON.parse(error.message)
284+
285+
if (message.error) {
286+
if (!radioTOSAgree.checked) {
287+
tosSection.classList.add('rainbow-border-highlight')
288+
}
289+
290+
Notification(`An error with PayPal happened. ${message.error}`)
291+
return
292+
}
293+
} catch {
294+
}
295+
}
296+
275297
const message = []
276298

277299
for (const [key, value] of Object.entries(error)) {
278300
message.push(`${key}: ${value}`)
279301
}
280302

281303
Notification(`An error with PayPal happened. More info in console. ${message.join(', ')}`)
282-
console.log(error)
304+
console.log({ error })
283305
},
284306

285307
onCancel () {

0 commit comments

Comments
 (0)