PHP code example of wdwp / yandexmoney

1. Go to this page and download the library: Download wdwp/yandexmoney 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/ */

    

wdwp / yandexmoney example snippets


use wdwp\yandexmoney\Payment;

$payment = new Payment(
    '4100163332366', 'Payment', 100.0, 'shop', 'AC'
);

$form = $payment->setFormcomment('Shop name')
    ->setDest('Payment for some goods')
    ->setLabel($order->id)
    ->setComment($order->comment)
    ->setSuccessUrl('http://yoursite.com/success.php')
    ->needFio(true)
    ->needEmail(true)
    ->needPhone(true)
    ->needAddress(true)
    ->getForm();

echo $form;

// redirect to payment url
$payment->send();

// get payment url
$url = $payment->getUrl();

// somewere in result url handler...
...
use wdwp\yandexmoney\Payment;

$result = Payment::validate($_POST, 'RX29rXHxOsR0exsBs6Hvi'); //secret word

if ($result) {
    // payment is valid
    $order = Orders::find($result['label']);      
   
}
...

...
echo "Thank you for your payment!";
...