Пример #1
0
 public function testGetRightsConfigurator()
 {
     $rightsConfigurator = YandexMoney::getRightsConfigurator();
     $this->assertNotNull($rightsConfigurator);
     $this->assertInstanceOf('YandexMoney\\Utils\\RightsConfigurator', $rightsConfigurator);
 }
Пример #2
0
use YandexMoney\Request\OperationHistoryRequest;
use YandexMoney\Request\P2pPaymentRequest;
use YandexMoney\Request\ProcessExternalPaymentRequest;
use YandexMoney\Request\ProcessPaymentByCardRequest;
use YandexMoney\Request\ProcessPaymentByWalletRequest;
use YandexMoney\YandexMoney;
$loader = (require __DIR__ . '/vendor/autoload.php');
$loader->add('YandexMoney', __DIR__ . '/../lib/');
$app = new Silex\Application();
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/views'));
/**
 * app route
 */
$app->get('/', function () use($app) {
    $rightsConfigurator = YandexMoney::getRightsConfigurator();
    $rightsConfigurator->addRight(Rights::ACCOUNT_INFO);
    $rightsConfigurator->addRight(Rights::OPERATION_HISTORY);
    $rightsConfigurator->addRight(Rights::OPERATION_DETAILS);
    $rightsConfigurator->paymentToAccount("410011161616877", PaymentIdentifier::ACCOUNT, 0, 30);
    $rightsConfigurator->paymentToPattern("337", 0, 30);
    $rightsConfigurator->setMoneySource(MoneySource::CARD);
    $authRequestBuilder = YandexMoney::getAuthRequestBuilder();
    $authRequestBuilder->setClientId(CLIENT_ID);
    $authRequestBuilder->setRedirectUri(REDIRECT_URI);
    $authRequestBuilder->setRights($rightsConfigurator->toString());
    $apiFacade = YandexMoney::getApiFacade();
    $apiFacade->setLogFile(__DIR__ . '/ym.log');
    $originalServerResponse = null;
    try {
        $originalServerResponse = $apiFacade->authorizeApplication($authRequestBuilder);