コード例 #1
0
 public function testMoneySourceToken()
 {
     $this->assertEquals("money_source_token", $this->processExternalPaymentRequest->getMoneySourceToken());
 }
コード例 #2
0
ファイル: index.php プロジェクト: a-t/yandex-money-sdk-php
/**
 *  app route
 */
$app->get('/request-external-payment', function (Request $request) use($app) {
    $apiFacade = YandexMoney::getApiFacade();
    $apiFacade->setLogFile(__DIR__ . '/ym.log');
    $externalPaymentResponse = null;
    $externalProcessPaymentResponse = null;
    try {
        $instanceIdResponse = $apiFacade->getInstanceId(CLIENT_ID);
        $externalPaymentP2pRequest = new ExternalP2pPaymentRequest();
        $externalPaymentP2pRequest->setTo("410011161616877");
        $externalPaymentP2pRequest->setAmount("20.50");
        $externalPaymentP2pRequest->setMessage("Message");
        $externalPaymentResponse = $apiFacade->requestExternalPaymentP2p($instanceIdResponse->getInstanceId(), $externalPaymentP2pRequest);
        $processExternalPaymentRequest = new ProcessExternalPaymentRequest();
        $processExternalPaymentRequest->setRequestId($externalPaymentResponse->getRequestId());
        $processExternalPaymentRequest->setInstanceId($instanceIdResponse->getInstanceId());
        $processExternalPaymentRequest->setExtAuthSuccessUri("http://somewhere.com/success");
        $processExternalPaymentRequest->setExtAuthFailUri("http://somewhere.com/fail");
        $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);
});
/**
コード例 #3
0
 /**
  * @param ProcessExternalPaymentRequest $processExternalPaymentRequest
  * @return Responses\ExternalProcessPaymentResponse
  */
 public function processExternalPaymentWithToken(ProcessExternalPaymentRequest $processExternalPaymentRequest)
 {
     $postParamsArray = $processExternalPaymentRequest->getDefinedParams();
     $apiNetworkClient = new ApiNetworkClient();
     $apiResponse = $apiNetworkClient->request($this->getApiUri(Uri::PROCESS_EXTERNAL_PAYMENT), http_build_query($postParamsArray));
     return new Responses\ExternalProcessPaymentResponse($apiResponse->getBodyJsonDecoded());
 }