Esempio n. 1
0
 */
$app->get('/p2p-payment', function (Request $request) use($app) {
    $token = $app['session']->get('token');
    $p2pPaymentRequest = new P2pPaymentRequest();
    $p2pPaymentRequest->setTo("410011161616877");
    $p2pPaymentRequest->setAmount("0.05");
    $p2pPaymentRequest->setComment("Comment");
    $p2pPaymentRequest->setMessage("Message");
    $p2pPaymentRequest->setTestPayment(true);
    $p2pPaymentRequest->setTestResult('success');
    $response = null;
    try {
        $apiFacade = YandexMoney::getApiFacade();
        $apiFacade->setLogFile(__DIR__ . '/ym.log');
        $response = $apiFacade->requestPaymentP2P($token, $p2pPaymentRequest);
        $processPaymentByWalletRequest = new ProcessPaymentByWalletRequest();
        $processPaymentByWalletRequest->setRequestId($response->getRequestId());
        $response = $apiFacade->processPaymentByWallet($token, $processPaymentByWalletRequest);
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    $result = 'Empty result';
    if ($response != null) {
        $result = $response->isSuccess() ? $response->getStatus() : $response->getError();
    }
    return $app['twig']->render('p2p-payment.twig', array('result' => $result));
});
/**
 *  app route
 */
$app->get('/shop-payment', function (Request $request) use($app) {
Esempio n. 2
0
 /**
  * @param string $accessToken
  * @param \YandexMoney\Request\ProcessPaymentByWalletRequest $paymentByWalletRequest
  * @internal param string|\YandexMoney\Request\ProcessPaymentByWalletRequest $requestId
  * @return \YandexMoney\Response\ProcessPaymentResponse
  */
 public function processPaymentByWallet($accessToken, ProcessPaymentByWalletRequest $paymentByWalletRequest)
 {
     $paramArray = $paymentByWalletRequest->getDefinedParams();
     $paramArray[ApiKey::MONEY_SOURCE] = ApiValue::WALLET;
     $params = http_build_query($paramArray);
     $apiNetworkClient = new ApiNetworkClient($accessToken, $this->logFile);
     $response = $apiNetworkClient->request($this->getApiUri(Uri::PROCESS_PAYMENT), $params);
     return new Responses\ProcessPaymentResponse($response->getBodyJsonDecoded());
 }