Koin Paypal implementation
HTML
<!-- The URL may vary during story development, but it will always be supplied by Dreck (http://dreck.sandbox.us-east-1.despegar.net/dreck/content?locale=es_AR&flow=CHECKOUT) -->
<script src="https://portal-dev.koin.com.br/checkout/sdk/v1/methods.js"></script>
<!-- Container where the PayPal button will be mounted -->
<div id="paypal-button-container"></div>
JavaScript
(async () => {
// This orderId is returned in "Create Payment Order" service
// (https://docs.google.com/document/d/1lJ1WALQX5FE1qm6OprN3JGm0NIN2bqXFSgxrXWqYC58/edit?usp=sharing)
const orderId = "d89536e4-c04c-4408-9a1e-026b5d962d2a";
// Load koinPayments SDK
const wallet = await KoinPayments.order(orderId);
// Setup callbacks before initialization
wallet.onError((error) => {
console.log('Payment Error:', error);
});
wallet.onSuccess((data) => {
console.log('Payment Success:', data);
});
// Initialize the wallet
wallet.initialize(() => {
console.log("Wallet SDK initialized");
// Mount PayPal button
wallet.mount("#paypal-button-container");
});
})();