Пример #1
0
 public function testUserChangeRecurring()
 {
     $Client = new Client(111, 222);
     $Request = $Client->userChangeRecurring('333');
     $this->assertEquals(['project' => '111', 'user' => '333', 'signature' => 'f68c15c701dd75d0d20436a7b5a4254a5ea8b772e4bd6ddb288269a1522780f3'], $this->getRequestParametersProperty($Request));
     $Request = $Client->userChangeRecurring('333', 7);
     $this->assertEquals(['project' => '111', 'user' => '333', 'interval' => 7, 'signature' => '68705471ac675e3c7fa8a2d48d4fdcf41a6841430b515ae9ee0e28cfc5bd3c73'], $this->getRequestParametersProperty($Request));
     $Request = $Client->userChangeRecurring('333', 7, 5.55);
     $this->assertEquals(['project' => '111', 'user' => '333', 'interval' => 7, 'price' => 5.55, 'signature' => 'f06580ca71a20f108b1089169ef2ce381aa7e73aadbbd2e9a0de5f4b263a4db0'], $this->getRequestParametersProperty($Request));
     $Request = $Client->userChangeRecurring('333', 7, 5.55, 'USD');
     $this->assertEquals(['project' => '111', 'user' => '333', 'interval' => 7, 'price' => 5.55, 'currency' => 'USD', 'signature' => '073d7e8aadbf245ae7c9478c161c4deb34d43d7f6493452cbbe8f5631b389c42'], $this->getRequestParametersProperty($Request));
 }
$privateKey = '';
$publicKey = '';
$user = '';
$Command = new CommandPosix();
$Command->appendHelpParameter('show help');
$Command->appendParameter(new Option('currency', 'c', 'recurring currency code (ISO 4217)', Option::TYPE_STRING), function ($name, $value) use(&$currency) {
    $currency = (string) $value;
});
$Command->appendParameter(new Option('interval', 'i', 'automatic recurring interval in days (if set 0, then only manual recurring will remain active)', Option::TYPE_STRING), function ($name, $value) use(&$interval) {
    $interval = (int) $value;
});
$Command->appendParameter(new Option('price', 'p', 'recurring payment price', Option::TYPE_STRING), function ($name, $value) use(&$price) {
    $price = (double) $value;
});
$Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) {
    $privateKey = (string) $value;
});
$Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) {
    $publicKey = (string) $value;
});
$Command->appendParameter(new Option('user', 'u', 'user identifier', Option::TYPE_STRING, true), function ($name, $value) use(&$user) {
    $user = (string) $value;
});
try {
    $Command->parse(true);
    $Client = new Client($publicKey, $privateKey);
    $Response = $Client->userChangeRecurring($user, $interval, $price, $currency)->execute();
    printf("%s\n", $Response);
} catch (RequiredOptionException $Ex) {
    $Command->displayHelp();
}