Sha256: 160d4f17ff44dc169bb39a38f180554c5dbe52ef64466fa632ff87991fa13271

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

<!doctype html>
<html>
<head>
  <title>veritrans-ruby demo</title>
  <link rel="icon" type="image/x-icon" href="https://account.midtrans.com/favicon.ico" />
  <link rel="stylesheet" href="/style.css">
</head>
<body>

<header>
  <h3>
    <a href="/">Midtrans sinatra app</a>
  </h3>
  <a href="https://github.com/veritrans/veritrans-ruby" class="github">Source Code</a>
</header>

<section>
  <h4>Midtrans SNAP example</h4>

  <section>
    <p>
      <label>Snap Token</label>
      <input type="text" id="token" value="<%= @token %>" readonly size="50">
    </p>
    <button id="snap_pay">Pay Now</button>
  </section>

  <p>
    To complete payment in sandbox mode, plese use <a href="https://docs.midtrans.com/en/api/test_credentials.html" target="_blank">testing credentials</a>.<br/>
    For more details see <a href="https://snap-docs.midtrans.com/">SNAP Documentation</a>
  <p>

  <code>
    <pre class="callback-result"></pre>
  </code>
</section>

<script src="https://app.sandbox.midtrans.com/snap/snap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script type="text/javascript">
$('#snap_pay').on('click', function (e) {
  e.preventDefault();
  snap.pay($('#token').val() + "?locale=en", {
    onSuccess: function (res) {
      console.log('onSuccess', res);
      $('.callback-result').text("SNAP Callback parameters:\n" + JSON.stringify(res, null, 4));
      if (confirm(res.status_message + "\nRedirect to confirm page?")) {
        window.location = "/widget/confirm/" + res.transaction_id;
      }
    },
    onPending: function (res) {
      console.log('onPending', res);
    },
    onError: function (res) {
      console.log('onError', res);
    }
  });
});
</script>

</body>
</html>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritrans-2.3.0 example/sinatra/widget.erb
veritrans-2.2.0 example/sinatra/widget.erb