Created with Sketch.
Created with Sketch.
Checkout 2.0

Callback

Avarda checkout needs to be able to send a callback to Merchant. If a callback is discovered the checkout iframe needs to be reloaded (javascript:AvardaCheckoutClient.init()) with the same original purchaseId. Purchaseid is submitted as querystring parameter in the callback. CallbackURL is defined in the javascript option Querystring Parameters (purchaseId, callback, PaymentSatus).

Server side – Callback page

if (!string.IsNullOrWhiteSpace(Callback) && (Callback.Equals("1") || Callback.Equals("2")))
{
//Load iframe with original purchaseid submitted in the Querystring
//no initializePurchase should be called
//Callback == 1 then the call back is due to card payment
//Callback == 2 then the call back is due to session cookie setting for safari
}
else if (!string.IsNullOrWhiteSpace(PaymentStatus) && !String.IsNullOrWhiteSpace(Purchaseid))
{
if ( PaymentStatus.Equals("Success)) {
//succsessfull direct bank payment detected - redirect to done page.
return RedirectToAction("Done", new {purchaseid = purchaseid });
}
else
{
//unsuccessfull direct bank payment -
//Load iframe with original purchaseid submitted in querystring
//no intializePurchase should be called
}
}
else
{
//no callback detected - treat the request as new purchase.
//call initializePurchase and get purchaseid
}

Java script – callback url

<script type="text/javascript">
var url ="http://localhost:50423/Avarda/index?purchaseId=@Html.Raw(Model.PurchaseID)"

// See IInitOptions interface for availible options.
   var options = {
    divId: "CheckOutDiv",
    purchaseId: "@Html.Raw(Model.PurchaseID)",
    callbackUrl: url,
      done: function(purchaseId) {
        window.location.href = "/Avarda/Done?purchaseId=@Html.Raw(Model.PurchaseID)";
      },
    customCssUrl: "",
    replaceDefaultCss: false,
    redirectUrl: "http://localhost:50423/home/"
}
AvardaCheckOutClient.init(otions);
</script>

K