feat: remove payment

This commit is contained in:
Julian Tölle 2023-03-25 21:24:54 +01:00
parent 897acf27de
commit b42145b54e
10 changed files with 2044 additions and 1098 deletions

View file

@ -1,52 +0,0 @@
<script lang="ts">
export let priceEur: number;
function paypalLoaded() {
paypal
.Buttons({
createOrder: (data, actions: any) => {
return actions.order.create({
// Payment will be captured in endpoint /api/process-order
intent: "AUTHORIZE",
purchase_units: [
{
amount: {
value: `${priceEur}`,
},
description: 'Hörbuch Download "Ein Pfeil am rechten Fleck"',
},
],
applicationContext: {
brand_name: "Ein Pfeil am Rechten Fleck",
shipping_preference: "NO_SHIPPING",
user_action: "PAY_NOW",
},
});
},
onApprove: (data) => {
// Sent order to backend to capture funds, save data to db and send email with download link
console.log("onApprove", data);
},
onError: (data) => {
// Show error to user
console.log("onError", data);
},
onCancel: (data) => {
console.log("onCancel", data);
},
})
.render("#paypal-checkout");
}
</script>
<svelte:head>
<script
src={`https://www.paypal.com/sdk/js?currency=EUR&client-id=${
import.meta.env.VITE_PAYPAL_CLIENT_ID
}&debug=true`}
on:load={paypalLoaded}></script>
</svelte:head>
<div id="paypal-checkout" />

View file

@ -1,45 +0,0 @@
<script lang="ts">
export let name: string;
export let features: string[];
export let price: string;
export let selected: boolean;
</script>
<div
class="{selected
? 'bg-gray-100'
: 'bg-gray-500'} flex flex-wrap items-start justify-start transition duration-500 ease-in-out border-2 border-gray-600 rounded-lg"
>
<div class="w-full md:w-3/4">
<div class="relative flex flex-col h-full p-8">
<h2
class="mb-4 {selected
? 'font-extrabold'
: 'font-semibold'} transition-all tracking-widest text-gray-800 uppercase"
>
{name}
</h2>
<ul class="list-disc list-inside">
{#each features as feature}
<li class="mb-2 text-lg font-normal tracking-wide flex-shrink-0 h-5 text-gray-800">
{feature}
</li>
{/each}
</ul>
</div>
</div>
<div class="w-full md:w-1/4 lg:ml-auto transition ease-in-out duration-1000">
<div class="relative flex flex-col h-full p-8">
<h1 class="mx-auto text-3xl leading-none">
{price}
</h1>
<p
class="{selected
? ''
: 'invisible'} transition-all ease-in-out text-gray-500 duration-1000 mx-auto mt-6 text-xs"
>
Aktuell ausgewählt
</p>
</div>
</div>
</div>

View file

@ -1,12 +0,0 @@
import paypal from "@paypal/checkout-server-sdk";
// Creating an environment
const clientId = import.meta.env.VITE_PAYPAL_CLIENT_ID;
const clientSecret = import.meta.env.PAYPAL_CLIENT_SECRET;
const environment =
import.meta.env.VITE_PAYPAL_ENV === "live"
? new paypal.core.LiveEnvironment(clientId, clientSecret)
: new paypal.core.SandboxEnvironment(clientId, clientSecret);
export const client = new paypal.core.PayPalHttpClient(environment);