PHP code example of soleniye / yoomoney-sdk-php

1. Go to this page and download the library: Download soleniye/yoomoney-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soleniye / yoomoney-sdk-php example snippets


     

    use \YooMoney\API;

    $auth_url = API::buildObtainTokenUrl($client_id, $redirect_uri, $scope);
    

    $access_token_response = API::getAccessToken($client_id, $code, $redirect_uri, $client_secret=NULL);
    if(property_exists($access_token_response, "error")) {
        // process error
    }
    $access_token = $access_token_response->access_token;
    

    $api = new API($access_token);

    // get account info
    $acount_info = $api->accountInfo();

    // check status 

    // get operation history with last 3 records
    $operation_history = $api->operationHistory(array("records"=>3));

    // check status 

    // make request payment
    $request_payment = $api->requestPayment(array(
        "pattern_id" => "p2p",
        "to" => $money_wallet,
        "amount_due" => $amount_due,
        "comment" => $comment,
        "message" => $message,
        "label" => $label,
    ));

    // check status 

    // call process payment to finish payment
    $process_payment = $api->processPayment(array(
        "request_id" => $request_payment->request_id,
    ));
    

API($access_token).requestPayment(array(
    test_payment => "true",
    // other params
));