Skip to content

Commit

Permalink
refactor(app): restored code to libs/payments.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousMagpie committed Nov 27, 2024
1 parent 503fd93 commit 7d0ce8a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions website/client/src/libs/payments.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// import getStore from '@/store';
import getStore from '@/store';

export function setup () { // eslint-disable-line import/prefer-default-export
// const store = getStore();
const store = getStore();

// // Set Amazon Payments as ready in the store,
// // Added here to make sure the listener is registered before the script can be executed
// window.onAmazonLoginReady = () => {
// store.state.isAmazonReady = true;
// window.amazon.Login.setClientId(process.env.AMAZON_PAYMENTS_CLIENT_ID);
// };
window.onAmazonLoginReady = () => {
store.state.isAmazonReady = true;
window.amazon.Login.setClientId(process.env.AMAZON_PAYMENTS_CLIENT_ID);
};

// Load the scripts

// Amazon Payments
// const amazonScript = document.createElement('script');
// let firstScript = document.getElementsByTagName('script')[0];
// amazonScript.type = 'text/javascript';
// amazonScript.async = true;
// amazonScript.src = `https://static-na.payments-amazon.com/OffAmazonPayments/us/${(process.env.AMAZON_PAYMENTS_MODE === 'sandbox' ? 'sandbox/' : '')}js/Widgets.js`;
// firstScript.parentNode.insertBefore(amazonScript, firstScript);
const amazonScript = document.createElement('script');
let firstScript = document.getElementsByTagName('script')[0];
amazonScript.type = 'text/javascript';
amazonScript.async = true;
amazonScript.src = `https://static-na.payments-amazon.com/OffAmazonPayments/us/${(process.env.AMAZON_PAYMENTS_MODE === 'sandbox' ? 'sandbox/' : '')}js/Widgets.js`;
firstScript.parentNode.insertBefore(amazonScript, firstScript);

// Stripe
const stripeScript = document.createElement('script');
// [firstScript] = document.getElementsByTagName('script');
[firstScript] = document.getElementsByTagName('script');
stripeScript.async = true;
stripeScript.src = 'https://js.stripe.com/v3/';
// firstScript.parentNode.insertBefore(stripeScript, firstScript);
firstScript.parentNode.insertBefore(stripeScript, firstScript);
}

0 comments on commit 7d0ce8a

Please sign in to comment.