Skip to content

Andrapple.mhtml #4

Description

@CodeAWS1

$ slack auth list

myworkspace (Team ID: T123ABC456)
User ID: U123ABC456

  • Last updated: 2024-02-04 12:00:00 -07:00
    Authorization Level: Workspace
    window.paypal
    .Buttons({
    style: {
    shape: "rect",
    layout: "vertical",
    },
    async createSubscription() {
    try {
    const response = await fetch("/api/paypal/create-subscription", {
    method: "POST",
    headers: {
    "Content-Type": "application/json",
    },
    body: JSON.stringify({ userAction: "SUBSCRIBE_NOW" }),
    });
    const data = await response.json();
    if (data?.id) {
    resultMessage(Successful subscription...<br><br>);
    return data.id;
    } else {
    console.error(
    { callback: "createSubscription", serverResponse: data },
    JSON.stringify(data, null, 2),
    );
    // (Optional) The following hides the button container and shows a message about why checkout can't be initiated
    const errorDetail = data?.details?.[0];
    resultMessage(
    Could not initiate PayPal Subscription...<br><br>${ errorDetail?.issue || "" } ${errorDetail?.description || data?.message || ""} +
    (data?.debug_id ? (${data.debug_id}) : ""),
    { hideButtons: true },
    );
    }
    } catch (error) {
    console.error(error);
    resultMessage(
    Could not initiate PayPal Subscription...<br><br>${error},
    );
    }
    },
    onApprove(data) {
    /*
    No need to activate manually since SUBSCRIBE_NOW is being used.
    Learn how to handle other user actions from our docs:
    https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create
    */
    if (data.orderID) {
    resultMessage(
    You have successfully subscribed to the plan. Your subscription id is: ${data.subscriptionID},
    );
    } else {
    resultMessage(
    Failed to activate the subscription: ${data.subscriptionID},
    );
    }
    },
    })
    .render("#paypal-button-container"); // Renders the PayPal button

// Example function to show a result to the user. Your site's UI library can be used instead.
function resultMessage(message) {
const container = document.querySelector("#result-message");
container.innerHTML = message;
}
window.paypal
.Buttons({
style: {
shape: "rect",
layout: "vertical",
},
async createOrder() {
try {
const response = await fetch("/api/orders", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
// use the "body" param to optionally pass additional order information
// like product ids and quantities
body: JSON.stringify({
cart: [
{
id: "YOUR_PRODUCT_ID",
quantity: "YOUR_PRODUCT_QUANTITY",
},
],
}),
});

    const orderData = await response.json();

    if (orderData.id) {
      return orderData.id;
    } else {
      const errorDetail = orderData?.details?.[0];
      const errorMessage = errorDetail
        ? `${errorDetail.issue} ${errorDetail.description} (${orderData.debug_id})`
        : JSON.stringify(orderData);

      throw new Error(errorMessage);
    }
  } catch (error) {
    console.error(error);
    resultMessage(`Could not initiate PayPal Checkout...<br><br>${error}`);
  }
},
async onApprove(data, actions) {
  try {
    const response = await fetch(`/api/orders/${data.orderID}/capture`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
    });

    const orderData = await response.json();
    // Three cases to handle:
    //   (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
    //   (2) Other non-recoverable errors -> Show a failure message
    //   (3) Successful transaction -> Show confirmation or thank you message

    const errorDetail = orderData?.details?.[0];

    if (errorDetail?.issue === "INSTRUMENT_DECLINED") {
      // (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
      // recoverable state, per https://developer.paypal.com/docs/checkout/standard/customize/handle-funding-failures/
      return actions.restart();
    } else if (errorDetail) {
      // (2) Other non-recoverable errors -> Show a failure message
      throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
    } else if (!orderData.purchase_units) {
      throw new Error(JSON.stringify(orderData));
    } else {
      // (3) Successful transaction -> Show confirmation or thank you message
      // Or go to another URL:  actions.redirect('thank_you.html');
      const transaction =
        orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
        orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
      resultMessage(
        `Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`,
      );
      console.log(
        "Capture result",
        orderData,
        JSON.stringify(orderData, null, 2),
      );
    }
  } catch (error) {
    console.error(error);
    resultMessage(
      `Sorry, your transaction could not be processed...<br><br>${error}`,
    );
  }
},

})
.render("#paypal-button-container");

// Example function to show a result to the user. Your site's UI library can be used instead.
function resultMessage(message) {
const container = document.querySelector("#result-message");
container.innerHTML = message;
}
https://www.facebook.com/share/r/e6q9dMD4yYw69Gi4/?mibextid=saVFRoimport express from "express";
import fetch from "node-fetch";
import "dotenv/config";
import path from "path";

const { PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT = 8888 } = process.env;
const base = "https://api-m.sandbox.paypal.com";
const app = express();

// host static files
app.use(express.static("client"));

// parse post params sent in body in json format
app.use(express.json());

/**

  • Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.

  • @see https://developer.paypal.com/api/rest/authentication/
    */
    const generateAccessToken = async () => {
    try {
    if (!PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET) {
    throw new Error("MISSING_API_CREDENTIALS");
    }
    const auth = Buffer.from(
    PAYPAL_CLIENT_ID + ":" + PAYPAL_CLIENT_SECRET,
    ).toString("base64");
    const response = await fetch(${base}/v1/oauth2/token, {
    method: "POST",
    body: "grant_type=client_credentials",
    headers: {
    Authorization: Basic ${auth},
    },
    });

    const data = await response.json();
    return data.access_token;
    } catch (error) {
    console.error("Failed to generate Access Token:", error);
    }
    };

/**

  • Create an order to start the transaction.
  • @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
    */
    const createOrder = async (cart) => {
    // use the cart information passed from the front-end to calculate the purchase unit details
    console.log(
    "shopping cart information passed from the frontend createOrder() callback:",
    cart,
    );

const accessToken = await generateAccessToken();
const url = ${base}/v2/checkout/orders;
const payload = {
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "USD",
value: "100.00",
},
},
],
};

const response = await fetch(url, {
headers: {
"Content-Type": "application/json",
Authorization: Bearer ${accessToken},
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// "PayPal-Mock-Response": '{"mock_application_codes": "MISSING_REQUIRED_PARAMETER"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "PERMISSION_DENIED"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
},
method: "POST",
body: JSON.stringify(payload),
});

return handleResponse(response);
};

/**

const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: Bearer ${accessToken},
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// "PayPal-Mock-Response": '{"mock_application_codes": "INSTRUMENT_DECLINED"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "TRANSACTION_REFUSED"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
},
});

return handleResponse(response);
};

async function handleResponse(response) {
try {
const jsonResponse = await response.json();
return {
jsonResponse,
httpStatusCode: response.status,
};
} catch (err) {
const errorMessage = await response.text();
throw new Error(errorMessage);
}
}

app.post("/api/orders", async (req, res) => {
try {
// use the cart information passed from the front-end to calculate the order amount detals
const { cart } = req.body;
const { jsonResponse, httpStatusCode } = await createOrder(cart);
res.status(httpStatusCode).json(jsonResponse);
} catch (error) {
console.error("Failed to create order:", error);
res.status(500).json({ error: "Failed to create order." });
}
});

app.post("/api/orders/:orderID/capture", async (req, res) => {
try {
const { orderID } = req.params;
const { jsonResponse, httpStatusCode } = await captureOrder(orderID);
res.status(httpStatusCode).json(jsonResponse);
} catch (error) {
console.error("Failed to create order:", error);
res.status(500).json({ error: "Failed to capture order." });
}
});

// serve index.html
app.get("/", (req, res) => {
res.sendFile(path.resolve("./client/checkout.html"));
});

app.listen(PORT, () => {
console.log(Node server listening at http://localhost:${PORT}/);
});{
"KPlugin": {
"Authors": [
{
"Name": "various"
}
],
"Category": "Application Launchers",
"Description": "Search Applications and more",
"EnabledByDefault": true,
"Icon": "start-here-kde",
"Id": "org.kde.plasma.simplekickoff",
"License": "GPL-2.0+",
"Name": "Simple Application Launcher",
"ServiceTypes": [
"Plasma/Applet"
],
"Version": "2.5"
},
"X-Plasma-Provides": [
"org.kde.plasma.launchermenu"
],
"X-Plasma-RequiredExtensions": [
"LaunchApp"
]
}
Error
Error while processing login response: { "errorMessage": "", "errorCode": 512 }.address.
Code: REG-PAYGO-UPGRADE-ATSA7PBB2ZPC1Code: REG-PAYGO-UPGRADE-BTZMHDT82LPC5 #Copy .env.example to .env:

cp -a .env.example .env

#Generate a key:
php artisan key:generate

#Only then run:
php artisan servehttps://forms.office.com/Pages/AnalysisPage.aspx?AnalyzerToken=nadPUThGQOYklVBSHSXqJvJ9motMzSIshttps://forms.office.com/Pages/AnalysisPage.aspx?AnalyzerToken=nadPUThGQOYklVBSHSXqJvJ9motMzSIs&id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAN__nLB5zZUNzlGMkEzSERTRjJPSUtRUU5IUDJHRlhZTi4uhttps://forms.office.com/Pages/DesignPageV2.aspx?prevorigin=rbf&origin=NeoPortalPage&rpring=UsGovGccProduction&rpsession=fa4a2e4c-474e-40ea-b004-19aa3c50cd77&subpage=design&id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAN__nLB5zZUNzlGMkEzSERTRjJPSUtRUU5IUDJHRlhZTi4u&branchingelementid=re4923808a99c428dad403026e34c573d&analysis=true&topview=Presentationhttps://forms.office.com/r/fPKqZ5DR7U?origin=lprLinkHTML:
<iframe src="https://snapcraft.io/slack/embedded?button=black" frameborder="0" width="100%" height="410px" style="border: 1px solid #CCC; border-radius: 2px;"></iframe>https://join.slack.com/t/codeaws1/shared_invite/zt-2c0zxp9hw-dgDTJ2oaddvCwHR9Ital8ghttps://codeaws1.slack.com/apphttps://join.slack.com/t/slack-nrr4703/shared_invite/zt-2c0zxp9hw-dgDTJ2oaddvCwHR9Ital8gcurl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash https://aur.archlinux.org/snapd.git$ slack login

📋 Run the following slash command in any Slack channel or DM
This will open a modal with user permissions for you to approve
Once approved, a challenge code will be generated in Slack

/slackauthticket ABC123defABC123defABC123defABC123defXYZ

? Enter challenge code
? Enter challenge code eXaMpLeCoDe

✅ You've successfully authenticated! 🎉
Authorization data was saved to ~/.slack/credentials.json

💡 Get started by creating a new app with slack create my-app
Explore the details of available commands with slack help
$ slack auth list

myworkspace (Team ID: T123ABC456)
User ID: U123ABC456
Last updated: 2023-01-01 12:00:00 -07:00
Authorization Level: Workspace
slack create my-app --template https://github.com/slack-samples/deno-starter-template
? Choose a local environment

Install to a new workspace or organization
cd my-app

https://aur.archlinux.org/snapd.git

1707083481716.gif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions