pay.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrom=1">
  4. </head>
  5. <body>
  6. <button id="MM-button"></button>
  7. <script src="https://pay.woop-woop.cn:41102/payment/js/cps-checkout.js"></script>
  8. <script type="text/javascript">
  9. totalPrice=1;
  10. MMPay.Button.render({
  11. env: 'sandbox', // Optional: specify 'sandbox' environment
  12. payment: function () {
  13. if (null == totalPrice || totalPrice <= 0)// Determine whether to select the purchased goods.
  14. {
  15. alert("Payment amount must be greater than zero.");
  16. return;
  17. }
  18. //The merchant can customize parameters to be transferred as required.
  19. var data =
  20. {
  21. env: this.evn,
  22. totalPrice: totalPrice
  23. };
  24. var CREATE_URL = 'http://www.tp6.com/index/create';
  25. return MMPay.payment.create(CREATE_URL, data)
  26. .then(function(res){
  27. return res.paymentID;
  28. });
  29. },
  30. onAuthorize: function (data) {
  31. var EXECUTE_URL = 'https://10.93.49.141:8443/portal-service-demo/biz_pgw/demo/checkout/api/payment/execute'
  32. var data =
  33. {
  34. env: this.env,
  35. paymentID: data.paymentID,
  36. payerID: data.payerID,
  37. couponID: data.couponID
  38. };
  39. // Make a call to your server to execute the payment
  40. return MMPay.payment.execute(EXECUTE_URL, data)
  41. .then(function (res) {
  42. //window.location.href = "https://10.61.36.177:8443/portal-service-demo/success.jsp?paymentID="+res.paymentID;
  43. });
  44. },
  45. onError:function(data)
  46. {
  47. window.location.href = "https://10.93.49.141:8443/portal-service-demo/failure.jsp"; // Page to which a merchant wants to jump after a transaction fails.
  48. },
  49. onCancel:function(data)
  50. {
  51. window.location.href = "https://10.93.49.141:8443/portal-service-demo/";// Page to which a merchant wants to jump after a transaction is canceled.
  52. }
  53. }, 'MM-button');
  54. </script>
  55. </body>
  56. </html>