struct ContentView: View {
//Create a view model instance to use later
@ObservedObject var viewModel = KKiaPayViewModel()
@State private var showWebView = false
//Initialise the Kkiapay Instance
private var kkiaPay: KKiaPay{
publicAPIKey: "xxxxxxxxxxxxxxxxxxx",
sandbox: true,//set this to false in production
callback: "https://redirect.kkiapay.com",
.sheet(isPresented: $showWebView) {
//Get the transaction data back
kkiaPay.onReceive(self.viewModel.paymentData.receive(on: RunLoop.main)){paymentData in
if(paymentData.isSuccessful){
print("The amount of the transaction is " + paymentData.amount+" with id "+paymentData.transactionId)
print("The payment was not successful")
struct ContentView_Previews: PreviewProvider {
static var previews: some View {