• Hello, I have developed a payment Gateway plugin called SADDAD, that is connected with an API of local online payment similar to paypal. I used to get OTP also my customers when they hit the get OTP button. somehow after recent wordpress update I am not able to get this OTP. I feel that something is blocking this request. I couldnt debug the problem.

    can someone help figure out the issue please.

    • This topic was modified 3 years, 1 month ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    Please provide the relevant code that executes when the Get OTP button is clicked. If it’s more than a couple dozen lines, please post at pastebin.com or gist.github.com and just provide the link here.

    Also, what response, if any, comes back from the API server?

    Thread Starter elyshop

    (@elyshop)

    Hello sorry for the delay, here is the code:

    <script>
                    jQuery("#get-otp").on('click', function(e) {
    
                        e.preventDefault();
                        jQuery.ajax({
                            type: "POST",
                            url: "https://e-ly.shop/wp-admin/admin-ajax.php",
                            data: {
                                action: 'send_user_otp',
                                phone_number: 0914864917,
                                birthyear: jQuery("input[name='birth_date']").val(),
                                order_id: 3204,
                                order_total: 50.00,
                                token: '***********************************',
                                url: 'https://pgw.almadar.ly/api/',
                                category: 20                        },
                            success: function(response) {
                                if (isNaN(response)) {
    
                                    alert(response);
    								console.log(response)
    
                                } else {
    
                                    let transactionID = response;
                                    jQuery("#transaction_id").val(transactionID);
                                  
                                }
                            }
    
                        });
    
                    });
    
                    jQuery("#pay_sadad").on("click", function(e) {
    
                        e.preventDefault();
    
                        e.preventDefault();
                        jQuery.ajax({
                            type: "POST",
                            url: "https://e-ly.shop/wp-admin/admin-ajax.php",
                            data: {
                                action: 'pay_invoice',
                                transaction_id: jQuery("#transaction_id").val(),
                                OTP: jQuery("#OTP").val(),
    
                                token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiU2FkYWRQR1ciLCJjb3Jwb3JhdGVTZXJ2aWNlSWQiOjEzNTAsImFwcElkIjoiZmE1MjhiY2Q5ZjRiNGZiZWExYzRmOTI4ZTU3Nzg3NzkiLCJleHAiOjE2NTM2NTI0NzEsImlzcyI6IkNvcmV0ZWMiLCJhdWQiOiJTQURBRFBHVyJ9.CL6M9gmbvk698m5lExmIn734pTEbU6dIMbYBRI013ho',
                                url: 'https://pgw.almadar.ly/api/',
    
                            },
                            success: function(response) {
                                console.log(response);
                                if (response == 0) {
    
                                    jQuery.ajax({
                                        type: "POST",
                                        url: "https://e-ly.shop/wp-admin/admin-ajax.php",
                                        data: {
                                            action: 'update_order_on_success',
                                            order_id: 3204,
    
                                        },
                                        success: function(response) {
    
                                            window.location.href = response;
    
                                        }
    
                                    });
    
                                }
                            }
    
                        });
    
                    });
    Thread Starter elyshop

    (@elyshop)

    I get no response to the API

    Moderator bcworkz

    (@bcworkz)

    Try adding dataType : 'json', to the .ajax() parameters. Its default data type is not easily processed by admin-ajax.php

    Thread Starter elyshop

    (@elyshop)

    sorry where to add it in the code

    Thread Starter elyshop

    (@elyshop)

    I added it under data: {

    on both ,nothing happened. I used troubleshooting API request and the error i get is Cannot parse the body

    Moderator bcworkz

    (@bcworkz)

    If the API can provide an error about the body, then the request properly reached the Ajax callback. The API doesn’t like the data that was sent for some reason. Refer to the API documentation for what’s required. Compare against what is actually sent.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I cant do OTP request anymore’ is closed to new replies.