Skip to content

Instantly share code, notes, and snippets.

@listepo
Created January 21, 2015 13:35
Show Gist options
  • Save listepo/948018c9dd138a8cf2b9 to your computer and use it in GitHub Desktop.
Save listepo/948018c9dd138a8cf2b9 to your computer and use it in GitHub Desktop.
<?php
ob_start();
var_dump($_POST);
echo "\r\n----------------------------\r\n";
require_once ( __DIR__ . '/lib/N1/vendor/autoload.php');
$config = [
'apiUrl' => 'https://processingsandbox.n1.ua/',
'clientName' => 'easytax',
'privateKey' => <<<RSA
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA3IuUwt6MpTOg7eieTEninZ0HgQ0X3mnTd88X6byBDyI5pZCI
aOxylqnTxVl1CwIOcafuooxfmQXmYwPmElIDNN+8z37CgSQ89Y66vd3JYgt1bFID
2NPAAy/iPXh6JC1FA7l3xj+49HzYBoX1qzV8QbZaDuU2EslnmsT8pB4+2C53AuTA
aW5RReTMgxi0q/e6HN1uYH2iRuFUHsS9cbLg4FAUURWvlSCBuVrLeZY//w+a8cju
pED9X4Xf8JwIbLVrvcbVd0AHHOZz/c2aTiHwMjQpIawjhb8ZV063jKFyw4Oz09Wy
j76rlfNN8S2fY+6A0bNzUXLtp1l/xXAAUFFNRQIDAQABAoIBAQCTvu5pna2a/ntQ
5gUmFlk6PXhJe/wBg+Om35WlgCL1gHgd8jVwFPau+BZmnwdJ2JbUjSvQuTlRyiIN
Mw9uNoLvaPOUDdc/rIcp+fQgPfQrOoHvjwIEv9ZiTDHD/HHWynzxgc47gXTmVLxj
olpx1+LmIsMyN1uCOmqtxEl7qMdxCnFSF3xb95S5kq425IuSjSLghjkV6fm+WKpM
ihZmWJwMuTWTpcpymPDVZiGBI1vwd5xdEHc2jGnAmjrabY24ukiYwsyKWjARI+0x
jTdsoK/udrazINSUCrEcyQI+M2bmJvMY6Vw0JcT7mvYYh9yOKACCVZpPRVv6gDXU
keeqPioBAoGBAO67rBwETI4dHuOrp8DNxLkFacjiT/NHPlnZlZMtJhZGER2dkPA0
t93rcE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qzV8
QbZaDuU2EslnmsT8pB4+2C53AuTAaW5RReTMgxi0q/e6HN1uYH2iRuFUHsS9cbLg
4FAUURWvlSCBuVrLeZY//w+a8cjupED9X4Xf8JwIbLVrvcbVd0AHHOZz/c2aTiHw
MjQpIawjhb8ZV063jKFyw4Oz09Wyj76rlfNN8S2fY+6A0bNzUXLtp1l/xXAAUFFN
RQIDAQAB
-----END PUBLIC KEY-----
RSA
,
];
class MyCoolProcessor implements \N1\Client\IncomingRequest\IOrderPaymentProcessor
{
/**
* @param \N1\Xml\Request\CoreReceiver\Notify $request
* @return \N1\Xml\Response\Notify
*/
public function confirm(\N1\Xml\Request\CoreReceiver\Notify $request)
{
echo "\r\n----REQUEST------------------------\r\n";
var_dump($request);
echo "\r\n----REQUEST------------------------\r\n";
return new \N1\Xml\Response\Notify();
}
}
$requestProcessor = (new \N1\Client\Factory($config))->getRequestProcessor(new MyCoolProcessor());
try {
$plainRequest = $_POST;
$plainResponse = $requestProcessor->processRequest($plainRequest);
} catch (Exception $e) {
$plainResponse = $requestProcessor->processException($e);
}
echo $plainResponse;
echo "\r\n----------------------------\r\n";
$buffer = ob_get_contents();
ob_end_clean();
$fp = fopen( __DIR__ . '/response_test.txt', 'a+');
fwrite($fp, $buffer);
fwrite($fp, "\r\n----------------------------\r\n");
fclose($fp);
echo $plainResponse;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment