0

I want connect Vuejs with Local Payment Gateway,

add plugin on index.html

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
<script src="https://staging.doku.com/doku-js/assets/js/payment.js?version=<?php echo time()?>"></script> <!-- To prevent js caching -->
<link href="https://staging.doku.com/doku-js/assets/css/doku.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">

here below my methods

showPaymentPage() {
  post("payment/credit-card", {
    amount: this.amount+'.00',
    invoice: this.invoiceNumber,
    currency: 360
  })
    .then(res => {
      if (res.data) {
        console.log(res.data);
        // this.payment = res.data.message
        const data = new Object();
            data.req_merchant_code = res.data.data.mallid; //mall id or merchant id
            data.req_chain_merchant = 'NA'; //chain merchant id
            data.req_payment_channel = '15'; //payment channel
            data.req_transaction_id = res.data.data.invoice; //invoice no
            data.req_amount = res.data.data.amount;
            data.req_currency = res.data.data.currency; //360 for IDR
            data.req_words = res.data.words; //your merchant unique key
            data.req_session_id = new Date().getTime(); //your server timestamp
            data.req_form_type = 'full';
            data.req_customer_id = this.$store.getters.getUser.id;

            getForm(data);
      }
    })
    .catch(e => {
      console.log(e);
    });
},

but get response on console log like below

TypeError: $.ajax(...).success is not a function
at getForm (payment.js?version=1579060503:1)
at app.js:35908

Please help me,

3 Answers3

0

It looks to me like there is no success function defined. Just bear in mind that jquery does not use promises, meaning you can not do .then/.catch

rmiguelrivero
  • 926
  • 8
  • 8
0

Your code is correct there is no problem with it but with jQuery's recent update, .success() method is no longer allowed so the code below will emit an error.

$.ajax(url).success

For newer version of jquery, you can do:

$.ajax(url, {
  success: () => {
    // Do something
  }
})

Or

$.ajax({
  type: "GET",
  url,
  success: function () { 
    // Do something
  }
})

Or, you can simple use chain method like so:

$.ajax(url).then(x => {
  // Do something
})

Or

$.ajax(url).done(x => {
  // Do something
})
Karma Blackshaw
  • 880
  • 8
  • 20
0

There is no function ajax().success. You Can use something like this :

$.ajax({
      url: "getvalue.php",  
      success: function(data) {
         return data; 
      }
   });