$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); } catch (\Exception $e) { echo $e->getMessage(); } return new Response('', $originalServerResponse->getCode(), array('Location' => $originalServerResponse->getHeader('Location'))); }); /** * app route
public function testGetAuthRequestBuilder() { $authRequestBuilder = YandexMoney::getAuthRequestBuilder(); $this->assertNotNull($authRequestBuilder); $this->assertInstanceOf('YandexMoney\\Utils\\AuthRequestBuilder', $authRequestBuilder); }
public function testRedirectUriMethod() { $authRequestBuilder = YandexMoney::getAuthRequestBuilder(); $authRequestBuilder->setRedirectUri("YOUR_APP_REDIRECT_URI"); $this->assertEquals($authRequestBuilder->getRedirectUri(), "YOUR_APP_REDIRECT_URI"); }