TourIAm/TIAMSharedUI/Pages/SumupPayment.razor

34 lines
974 B
Plaintext

@page "/sumuppayment/{checkoutId}"
@inject IJSRuntime JSRuntime
@code {
[Parameter]
public string checkoutId { get; set; } = "";
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await JSRuntime.InvokeVoidAsync("loadSumUpPaymentWidget", checkoutId);
}
}
}
<div id="sumup-card"></div>
<script>
window.loadSumUpPaymentWidget = function (checkoutId) {
const script = document.createElement('script');
script.src = 'https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js';
script.onload = () => {
SumUpCard.mount({
id: 'sumup-card',
checkoutId: checkoutId,
onResponse: function (type, body) {
console.log('Type', type);
console.log('Body', body);
}
});
};
document.head.appendChild(script);
};
</script>