include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $publicKey = ''; $privateKey = ''; $payerResponse = ''; $merchantData = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('data', 'd', 'ACS merchant data', Option::TYPE_STRING, true), function ($name, $value) use(&$merchantData) { $merchantData = (string) $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('response', 'e', 'ACS payer response', Option::TYPE_STRING, true), function ($name, $value) use(&$payerResponse) { $payerResponse = (string) $value; }); try { $Command->parse(true); $Client = new Client($publicKey, $privateKey); $Response = $Client->cardAuthenticate($payerResponse, $merchantData)->execute(); printf("%s\n", $Response); } catch (RequiredOptionException $Ex) { $Command->displayHelp(); }
public function testCardAuthenticate() { $Client = new Client(111, 222); $Request = $Client->cardAuthenticate('payer authentication response', 'merchant data'); $this->assertEquals(['project' => '111', 'PaRes' => 'payer authentication response', 'MD' => 'merchant data', 'signature' => 'a3cef80d780843f81083cf3a9b15eadd4236c6f86a55c1a25b58c43850ba6154'], $this->getRequestParametersProperty($Request)); }