Advertisement
hasancse1991

checkout.html

Nov 8th, 2018
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.04 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.     <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  5.            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  6.            crossorigin="anonymous"></script>
  7.     <script src="file:///android_asset/www/js/bKash-checkout-sandbox.js"></script>
  8.     <style type="text/css">
  9.         @font-face {
  10.             font-family: MyFont;
  11.             src: url("file:///android_asset/fonts/Mark_Simonson_Proxima_Nova_Alt_Regular_webfont.ttf")
  12.         }
  13.         body {
  14.             text-align:center;
  15.             font-family: MyFont;
  16.         }
  17.         p {
  18.            font-weight: bold;
  19.            font-size: 16px;
  20.         }
  21.         button {
  22.             background-color: #0099cc;
  23.             padding: 16px;
  24.             color: white;
  25.         }
  26.     </style>
  27. </head>
  28.  
  29. <body>
  30. <img src="file:///android_asset/www/images/bkash_payment.png" width="80%"/><br><br>
  31. <p id="amount"></p><br><br>
  32. <button id="bKash_button">Pay With bKash</button>
  33. <script type="text/javascript">
  34.  
  35.         var paymentConfig = {
  36.             createCheckoutURL: "",
  37.             executeCheckoutURL: "",
  38.         };
  39.  
  40.         var paymentID = '';
  41.         var orderId = 0;
  42.  
  43.         bKash.init({
  44.             paymentMode: 'checkout',
  45.             paymentRequest: { amount: '0', intent: 'sale', orderId: 0 },
  46.  
  47.             createRequest: function (request) {
  48.                 $('#amount').html('Amount: ' + request.amount + ' BDT');
  49.                 $.ajax({
  50.                     url: paymentConfig.createCheckoutURL,
  51.                     type: 'POST',
  52.                     contentType: 'application/json',
  53.                     data: JSON.stringify(request),
  54.                     success: function (response) {
  55.                         if (response && response.response_code == 200 && response.data.paymentID != null) {
  56.                            orderId = request.orderId;
  57.                             paymentID = response.data.paymentID;
  58.                             bKash.create().onSuccess(response.data);
  59.                         } else {
  60.                             bKash.create().onError();//run clean up code
  61.                             window.location.href = "file:///android_asset/www/checkout_failed.html"
  62.                         }
  63.                     },
  64.                     error: function () {
  65.                         bKash.create().onError();//run clean up code
  66.                         window.location.href = "file:///android_asset/www/checkout_failed.html"
  67.                     }
  68.                 });
  69.             },
  70.             executeRequestOnAuthorization: function () {
  71.                 $.ajax({
  72.                     url: paymentConfig.executeCheckoutURL,
  73.                     type: 'POST',
  74.                     contentType: 'application/json',
  75.                     data: JSON.stringify({ "paymentID": paymentID, "orderId": orderId }),
  76.                     success: function (response) {
  77.                         if (response.data && response.response_code == 200 && response.data.paymentID != null) {
  78.                            window.location.href = "file:///android_asset/www/checkoutSuccess.html";
  79.                         } else {
  80.  
  81.                             bKash.execute().onError();//run clean up code
  82.                             window.location.href = "file:///android_asset/www/checkout_failed.html"
  83.                         }
  84.                     },
  85.                     error: function () {
  86.                         bKash.execute().onError();//run clean up code
  87.                         window.location.href = "file:///android_asset/www/checkout_failed.html"
  88.                     }
  89.                 });
  90.             }
  91.         });
  92.         function callReconfigure(val) {
  93.             bKash.reconfigure(val);
  94.         }
  95.         function clickPayButton() {
  96.             $("#bKash_button").trigger('click');
  97.         }
  98.         function setUrls(createCheckoutURL, executeCheckoutURL) {
  99.             paymentConfig.createCheckoutURL = createCheckoutURL;
  100.             paymentConfig.executeCheckoutURL = executeCheckoutURL;
  101.         }
  102.  
  103. </script>
  104. </body>
  105.  
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement