#
#
# artur #2015-05-13 19:16:03
PHP
# artur #, 2015-05-13 19:16:03

POST request to Yandex Money API, how?

Hello!
I'm trying to make a request:

$request = Request::factory('http://money.yandex.ru/quickpay/confirm.xml')
                ->method('POST')
                ->post(array(
                            'receiver' => '41001299****',
                            'quickpay-form' => 'shop',
                            'targets' => 'Интернет-магазин *****',
                            'sum' => '990',
                            'successURL' => 'http://site.net/result'
                        ))
                ->headers('Content-Type', 'application/x-www-form-urlencoded');

$response = $request->execute();

echo $response->body();

- the result is an empty page ...
Do not tell me what is the reason? MIME indicated, like nothing more is needed. The situation is such that it is impossible to show the form on the page and you need to redirect by clicking directly to the payment form on the money site...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-05-13
@liff

$ch = curl_init(' money.yandex.ru/quickpay/confirm.xml ');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode(DATA));
$result = curl_exec($ch);
$responseInfo = curl_getinfo($ch);
print_r([$result,responseInfo]);

B
bkosun, 2015-05-13
@bkosun

And what is a framework? If Kohana, then:

$result = Request::factory('http://money.yandex.ru/quickpay/confirm.xml')
    ->query(array(
            'receiver' => '41001299****',
            'quickpay-form' => 'shop',
            'targets' => 'Интернет-магазин *****',
            'sum' => '990',
            'sum' => '990',
            'successURL' => 'http://site.net/result',
        ))
    ->headers('Content-Type', 'application/x-www-form-urlencoded')
    ->method(HTTP_Request::POST)
    ->execute();

die($result->body());

or like this:
$params = array(
    'receiver' => '41001299****',
    'quickpay-form' => 'shop',
    'targets' => 'Интернет-магазин *****',
    'sum' => '990',
    'sum' => '990',
    'successURL' => 'http://site.net/result',
    );

$uri = 'http://money.yandex.ru/quickpay/confirm.xml' . '?' . http_build_query($params);

$result = Request::factory($uri)
    ->method(HTTP_Request::POST)
    ->execute()
    ->headers('Content-Type', 'application/x-www-form-urlencoded');

die($result->body());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question