Skip to content

Instantly share code, notes, and snippets.

@akoSalman
Created February 19, 2020 11:25
Show Gist options
  • Save akoSalman/12374857d246afff3c9589ffefbe46b3 to your computer and use it in GitHub Desktop.
Save akoSalman/12374857d246afff3c9589ffefbe46b3 to your computer and use it in GitHub Desktop.
Rubika Token
function noToken() {
return typeof rubika_token === typeof undefined;
}
function hasRubikaToken() {
return !noToken();
}
function isFromRubika() {
return !notRubika();
}
function notRubika() {
return typeof androidApp === typeof undefined;
}
function settleRubikaPayment() {
$.ajax({
type: 'POST',
url: '/settle_rubika_payment',
data: {order: order_id},
success: function (res) {
$("#final-payment-btn")
.prop("disabaled", true)
.addClass("gray-background")
.removeClass("green-background")
.text("پرداخت با موفقیت انجام شد.")
},
error: function (res) {
alert("خطایی اتفاق افتاده.")
}
})
}
$(document).ready(function () {
if (notRubika()) {
rubika_token = "2648avkciwlobyqkqyveensrguuhixhl";
} else {
rubika_token = androidApp.getUserToken();
}
});
function clientResponse(s) {
var res = JSON.parse(s);
if (res.track_id == order_id) {
settleRubikaPayment();
}
}
function goBack() {
if (isFromRubika()) {
androidApp.stopGoBack();
window.history.back();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment