Skip to content

Commit

Permalink
set default charge amount
Browse files Browse the repository at this point in the history
  • Loading branch information
alissacrane-cb committed Oct 15, 2024
1 parent 93dcced commit 504bd70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/components/OnchainStoreCart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export default function OnchainStoreCart() {
description,
pricing_type: 'fixed_price',
local_price: {
amount: totalSum.toString(),
// NOTE: set to 0 for simulation purposes,
// replace with totalSum.toString() in real app
amount: '0',
currency: 'USD',
},
};
return createCharge(chargeDetails);
}, [createCharge, quantities, totalSum]);
}, [createCharge, quantities]);

return (
<div className="-mx-[50vw] fixed right-1/2 bottom-0 left-1/2 w-screen border-gray-200 border-t bg-white">
Expand All @@ -56,7 +58,8 @@ export default function OnchainStoreCart() {
<PayButton
coinbaseBranded={true}
text="Pay with Crypto"
disabled={!totalSum}
// NOTE: comment back in to disable 0 amount in real app
// disabled={!totalSum}
/>
</Pay>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useCreateCharge.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback } from 'react';
import { COINBASE_COMMERCE_API_KEY } from 'src/config';

const COMMERCE_API_URL = 'https://api.commerce.coinbase.com';
import { COMMERCE_API_URL } from 'src/links';

type Price = {
amount: string;
Expand All @@ -16,7 +15,6 @@ export type ChargeDetails = {

const useCreateCharge = () => {
const createCharge = useCallback(async (chargeDetails: ChargeDetails) => {
console.log({ chargeDetails });
try {
const res = await fetch(`${COMMERCE_API_URL}/charges`, {
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions src/links.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const COMMERCE_API_URL = 'https://api.commerce.coinbase.com';
export const DISCORD_LINK = 'https://discord.gg/wTJ7besU';
export const FIGMA_LINK =
'https://www.figma.com/community/file/1370194397345450683/onchainkit';
Expand Down

0 comments on commit 504bd70

Please sign in to comment.