Skip to content

Commit

Permalink
add amount
Browse files Browse the repository at this point in the history
  • Loading branch information
ielijose committed Dec 7, 2023
1 parent 99bb7c6 commit 9e692c8
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/hooks/useNoRampModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export const useNoRampModal = (config: NoRampConfig) => {
async function applePay() {
const frame = iframeRef.current;

const outputElement = document.querySelector('#output');

if (!frame || !outputElement) {
if (!frame) {
return;
}

Expand All @@ -66,31 +64,36 @@ export const useNoRampModal = (config: NoRampConfig) => {
currency: 'usd',
total: {
label: 'NoRamp',
amount: 100,
amount: 0,
pending: true,
},
requestPayerName: true,
requestPayerEmail: true,
});

window.addEventListener('message', (event) => {
console.log('message event kit: ', event.data.type);

if (event.data.type) {
console.log('[kit] message event type: ', event.data.type);
}
if (event.data.type == 'letsGo') {

Check warning on line 78 in src/hooks/useNoRampModal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 16.x and ubuntu-latest

Expected '===' and instead saw '=='

Check warning on line 78 in src/hooks/useNoRampModal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 16.x and windows-latest

Expected '===' and instead saw '=='

Check warning on line 78 in src/hooks/useNoRampModal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 16.x and macOS-latest

Expected '===' and instead saw '=='

Check warning on line 78 in src/hooks/useNoRampModal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Expected '===' and instead saw '=='

Check warning on line 78 in src/hooks/useNoRampModal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and macOS-latest

Expected '===' and instead saw '=='
(async () => {
const result = await paymentRequest.canMakePayment();
console.log('result: ', result);

console.log('[kit] result: ', result);
if (result && result.applePay) {
frame.contentWindow?.postMessage(
{
type: 'canMakePayment',
},
'*'
);
} else {
console.error('Cannot make payment', result);
outputElement.innerHTML =
'<strong>Error:</strong> <code>paymentRequest.canMakePayment()</code> indicated Apple Pay cannot be used. Try opening this page in Safari and make sure you have a valid payment card in your Apple Wallet.';

paymentRequest.update({
total: {
label: 'NoRamp',
amount: event.data.amount,
pending: false,
},
});
}
})();
}
Expand All @@ -105,11 +108,11 @@ export const useNoRampModal = (config: NoRampConfig) => {
});

paymentRequest.on('paymentmethod', async (event) => {
outputElement.innerHTML =
'<p>Got a Payment Method: <code>' +
event.paymentMethod.id +
'</code></p><p>Sending it to the frame!</p>';

console.log(
'[kit] Got a Payment Method: ',
event.paymentMethod.id,
frame.contentWindow
);
paymentResponse = event;

frame.contentWindow?.postMessage({
Expand Down

1 comment on commit 9e692c8

@vercel
Copy link

@vercel vercel bot commented on 9e692c8 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

noramp-kit – ./

noramp-kit-noramp.vercel.app
noramp-kit.vercel.app
noramp-kit-git-main-noramp.vercel.app

Please sign in to comment.