getInstanceId() публичный статический Метод

Registers an instance of an application
См. также: http://api.yandex.com/money/doc/dg/reference/instance-id.xml
См. также: https://tech.yandex.ru/money/doc/dg/reference/instance-id-docpage/
public static getInstanceId ( string $client_id ) : response
$client_id string The client_id that was assigned to the application.
Результат response object
Пример #1
0
 private function getInstanceId()
 {
     $response = ExternalPayment::getInstanceId($this->params['client_id']);
     if ($response->status === 'success') {
         $this->instance_id = $response->instance_id;
     } else {
         throw new \Exception($response->error_message);
     }
 }
        $result = $api->process(array("request_id" => $request_id, "ext_auth_success_uri" => $base_path . "/external-success/", "ext_auth_fail_uri" => $base_path . "/external-fail/"));
        if ($result->status == "in_progress") {
            sleep(1);
        }
    } while ($result->status == "in_progress");
    $get_cookie_json = function ($cookie_name) use($app) {
        return json_decode($app->getCookie($cookie_name));
    };
    $codesamples_base = "external_payment/";
    return $app->render("cards.html", array("payment_result" => $result, "panels" => array("instance_id" => template_meta(array("code" => read_sample($codesamples_base . "obtain_instance_id.txt"), "response" => $get_cookie_json("result/instance_id")), 1), "request_payment" => template_meta(array("code" => read_sample($codesamples_base . "request_payment.txt"), "response" => $get_cookie_json("result/request")), 2), "process_payment1" => template_meta(array("code" => read_sample($codesamples_base . "process_payment1.txt"), "response" => $get_cookie_json("result/process")), 3), "process_payment2" => template_meta(array("code" => read_sample($codesamples_base . "process_payment2.txt"), "response" => $result), 4)), "home" => "../", "lang" => "PHP"));
});
$app->post("/wallet/process-external/", function () use($app) {
    $cookie_expired = "20 minutes";
    $wallet = $app->request->post("wallet");
    $value = $app->request->post("value");
    $instance_id_json = ExternalPayment::getInstanceId(CLIENT_ID);
    $app->setCookie("instance_id", $instance_id_json->instance_id, $cookie_expired, "/");
    $app->setCookie("result/instance_id", json_encode($instance_id_json), $cookie_expired, "/");
    $instance_id = $instance_id_json->instance_id;
    $api = new ExternalPayment($instance_id);
    $request_result = $api->request(array("pattern_id" => "p2p", "to" => $wallet, "amount_due" => $value, "comment" => "sample test payment", "message" => "sample test payment"));
    if ($request_result->status != "success") {
        $params = array("text" => json_encode($request_result, JSON_OPTIONS), "home" => "../");
        return show_error($params, $app);
    }
    $app->setCookie("request_id", $request_result->request_id, $cookie_expired, "/");
    $base_path = "http://" . $app->request->getHostWithPort() . $app->request->getPath() . "..";
    $process_result = $api->process(array("request_id" => $request_result->request_id, "ext_auth_success_uri" => $base_path . "/external-success/", "ext_auth_fail_uri" => $base_path . "/../external-fail/"));
    $app->setCookie("result/request", json_encode($request_result), $cookie_expired, "/");
    $app->setCookie("result/process", json_encode($process_result), $cookie_expired, "/");
    $url = sprintf("%s?%s", $process_result->acs_uri, http_build_query($process_result->acs_params));
 function testGetInstanceId()
 {
     $response = \YandexMoney\ExternalPayment::getInstanceId(CLIENT_ID);
     $this->assertEquals($response->status, "success");
 }