Пример #1
0
 public function testPutIfNotNull()
 {
     $apiFacade = YandexMoney::getApiFacade();
     $testArray = array();
     $apiFacade->putIfNotNull("1", $testArray, "one");
     $this->assertArrayHasKey("one", $testArray);
     $this->assertEquals("1", $testArray["one"]);
     $testArray = array();
     $apiFacade->putIfNotNull(null, $testArray, "one");
     $this->assertCount(0, $testArray);
 }
Пример #2
0
 public function testGetNotificationReceiver()
 {
     $notificationReceiver = YandexMoney::getNotificationReceiver(NOTIFICATION_SECRET);
     $this->assertNotNull($notificationReceiver);
     $this->assertInstanceOf('YandexMoney\\Utils\\NotificationReceiver', $notificationReceiver);
 }
<?php

ini_set('display_errors', 1);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../sample/consts.php';
use YandexMoney\YandexMoney;
$notificationReceiver = YandexMoney::getNotificationReceiver(NOTIFICATION_SECRET);
$logFile = fopen('testlog.txt', 'a+');
if ($notificationReceiver->receivedValidNotification()) {
    $notification = $notificationReceiver->getNotification();
    fwrite($logFile, "Request time: " . date("Y-m-d H:i:s", time()) . "\r\n");
    // Available on HTTP connection
    fwrite($logFile, $notification->getNotificationType() . "\r\n");
    fwrite($logFile, $notification->getOperationId() . "\r\n");
    fwrite($logFile, $notification->getAmount() . "\r\n");
    fwrite($logFile, $notification->getWithdrawAmount() . "\r\n");
    fwrite($logFile, $notification->getCurrency() . "\r\n");
    fwrite($logFile, $notification->getDatetime() . "\r\n");
    fwrite($logFile, $notification->getSender() . "\r\n");
    fwrite($logFile, $notification->getCodepro() . "\r\n");
    fwrite($logFile, $notification->getLabel() . "\r\n");
    fwrite($logFile, $notification->getSha1Hash() . "\r\n");
    fwrite($logFile, $notification->isTestNotification() . "\r\n");
    // Available on HTTPS connection
    fwrite($logFile, $notification->getLastName() . "\r\n");
    fwrite($logFile, $notification->getFirstName() . "\r\n");
    fwrite($logFile, $notification->getFathersName() . "\r\n");
    fwrite($logFile, $notification->getEmail() . "\r\n");
    fwrite($logFile, $notification->getPhone() . "\r\n");
    fwrite($logFile, $notification->getCity() . "\r\n");
    fwrite($logFile, $notification->getBuilding() . "\r\n");
Пример #4
0
        $externalProcessPaymentResponse = $apiFacade->processExternalPayment($processExternalPaymentRequest);
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    $response = array();
    if ($externalProcessPaymentResponse != null) {
        $response['result'] = $externalProcessPaymentResponse->isSuccess() ? $externalProcessPaymentResponse->getStatus() : $externalProcessPaymentResponse->getError();
    }
    return $app->json($response);
});
/**
 *  app route
 */
$app->get('/revoke-token', function (Request $request) use($app) {
    $token = $app['session']->get('token');
    $apiFacade = YandexMoney::getApiFacade();
    $apiFacade->setLogFile(__DIR__ . '/ym.log');
    $wasRevoked = false;
    try {
        $wasRevoked = $apiFacade->revokeOAuthToken($token);
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    $app['session']->set('token', null);
    return $app['twig']->render('revoke-token.twig', array('token_revoked' => $wasRevoked));
});
/**
 * Mode switcher
 */
if ($currentMode == APP_MODE) {
    $app->run();
 public function testRedirectUriMethod()
 {
     $authRequestBuilder = YandexMoney::getAuthRequestBuilder();
     $authRequestBuilder->setRedirectUri("YOUR_APP_REDIRECT_URI");
     $this->assertEquals($authRequestBuilder->getRedirectUri(), "YOUR_APP_REDIRECT_URI");
 }