Creating a return url for getting data from external api

You could register a rest route (ref: https://developer.wordpress.org/reference/functions/register_rest_route/).

In your case, something like this would do the trick:

register_rest_route( 'your-plugin/v1', '/payments/(?P<trans_id>\d+)(?:/(?P<amount>\d+))?', array(
        'methods' => 'GET',
        'callback' => array( $this, 'your_callback_function'),
        'args' => array(
          'trans_id' => array(
            'validate_callback' => function($param, $request, $key) {
              return is_numeric( $param );
            }
          ),
          'amount' => array(
            'validate_callback' => function($param, $request, $key) {
              return is_numeric( $param );
            }
          ),
        ),
    ) );

Figure out all of your parameters, setup validation here and then write yourself a callback function to do the actual work.

WordPress is moving down this path to replace the old admin-ajax api, and it’s pretty easy to work with. More info: https://developer.wordpress.org/rest-api/