This Health System uses the payment methods, Stripe and Paypal.
To test it as a developer in paying via Stripe, use the test card details provided here.
FRONTEND FOR STRIPE PAYMENT - CHECKOUT.HTML:
<script src="https://www.paypal.com/sdk/js?client-id={{paypal_client_id}}¤cy=USD"></script>
<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe("{{stripe_public_key}}");
var checkoutButton = document.getElementById("stripe-payment");
try {
checkoutButton.addEventListener("click", function () {
var email = "{{billing.patient.email}}";
checkoutButton.innerHTML = "Processing <i class='fas fa-spinner fa-spin ms-2'></i>";
fetch("/stripe_payment/{{billing.billing_id}}/", {
method: "POST",
body: JSON.stringify({ email: email }),
})
.then(function (response) {
return response.json();
})
.then(function (session) {
return stripe.redirectToCheckout({ sessionId: session.sessionId });
})
.then(function (result) {
if (result.error) {
alert(result.error.message);
}
})
.catch(function (error) {
console.log("Error: ", error);
});
});
} catch (error) {
console.log(error);
}
</script>
For Paypal, use the Sandbox. If you are testing as the MERCHANT, use the business account. If you are testing as the buyer, use the PERSONAL ACCOUNT. See the documentation here.
FRONTEND FOR PAYPAL PAYMENT - CHECKOUT.HTML:
<script src="https://www.paypal.com/sdk/js?client-id={{paypal_client_id}}¤cy=USD"></script>
<script>
function initPayPalButton() {
paypal
.Buttons({
style: {
shape: "rect",
color: "gold",
layout: "vertical",
label: "paypal",
},
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{ amount: { currency_code: "USD", value: "{{billing.total}}" } }],
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (orderData) {
// Full available details
console.log("Capture result", orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, for example:
const element = document.getElementById("paypal-button-container");
element.innerHTML = "";
element.innerHTML = "<h5>Verifying payment...</h5>";
window.location.href = `/paypal_payment_verify/{{billing.billing_id}}/?transaction_id=${orderData.id}`;
});
},
onError: function (err) {
//console.log(err);
console.error("PayPal Button Error:", err);
alert("An error occurred during the payment process. Please try again.");
},
})
.render("#paypal-button-container");
}
initPayPalButton();
</script>
No PDF file attached.