<script lang="ts">
import { createReevitStore } from '@reevit/svelte';
const store = createReevitStore({
config: {
publicKey: 'pfk_test_xxx.secret',
amount: 5000,
currency: 'GHS',
email: 'customer@example.com',
},
apiBaseUrl: 'http://localhost:8080',
onSuccess: (res) => console.log('Payment done!', res),
onError: (err) => console.error('Payment failed:', err),
});
$: state = $store;
</script>
<button on:click={() => store.initialize()}>Start Payment</button>
{#if state.status === 'ready'}
<div>
<h3>Select Payment Method</h3>
<button on:click={() => store.selectMethod('card')}>💳 Card</button>
<button on:click={() => store.selectMethod('mobile_money')}>📱 Mobile Money</button>
</div>
{/if}
{#if state.status === 'success'}
<div>✅ Payment successful!</div>
{/if}
{#if state.error}
<div class="error">
{state.error.message}
<button on:click={() => store.reset()}>Try Again</button>
</div>
{/if}