0

Hi I am integrating Instamojo in one of wordpress theme.I have used Instamojo class and related API functions to create API request, after execution it returns response but with 0 appened at last. I am not getting why that 0 comes. here is my code of instamojo api:

$api = new Instamojo\Instamojo($instamojo_api_key, $instamojo_auth_token); 
try {
    $response = $api->paymentRequestCreate(array(
    'purpose' => 'Test',
    'amount' =>  '20',
    'phone' => '8888888888',
    'buyer_name' => $username,
    'redirect_url' =>  'redirect_url',
    'send_sms' => false,
    "email" => $user_email
        ));
print($response["longurl"]);///here i am getting long_url but with 0
//// print(rtrim($response["longurl"],0));////tried to remove last 0 not working
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}

am I sending wrong data to API call or why does it return 0 as a response?

waka
  • 3,362
  • 9
  • 35
  • 54
Nil
  • 5
  • 6
  • I think this api does not have die in their function. . so it falls back to default wordpress `die(0)` function. . it may help you https://wordpress.stackexchange.com/questions/116759/why-does-wordpress-add-0-zero-to-an-ajax-response – hanish singla Sep 29 '17 at 05:14
  • I got where the actual problem was, in one method it returns 0 by default so i was getting 0 appended last to api response. its wrong in theme ,not in api code. :-) – Nil Sep 29 '17 at 06:01
  • @ hanish , Sorry i haven't saw your reply but yes it is the problem and i have solved it,still many thanks :-) – Nil Sep 29 '17 at 06:03

0 Answers0