mitalcoi/php-webmoney

WebMoney API PHP Library

v0.10.3 2015-04-01 07:59 UTC

This package is not auto-updated.

Last update: 2024-04-17 05:10:40 UTC


README

Packagist Dependency Status Packagist Packagist

Get transparent object-oriented interaction with WebMoney API.

If you just need to sign your requests to the API, use WebMoney Signer, a native PHP implementation of the WMSigner authentication module.

XML-interfaces supported

  • X2: transferring funds from one purse to another
  • X3: receiving transaction history, checking transaction status
  • X6: sending message to any WM-identifier via internal mail
  • X8: retrieving information about purse ownership, searching for system user by his/her identifier or purse
  • X9: retrieving information about purse balance
  • X11: retrieving information from client’s passport by WM-identifier
  • X14: fee-free refund
  • X17: operations with arbitration contracts
  • X18: getting transaction details via merchant.webmoney
  • X19: verifying personal information for the owner of a WM identifier

Megastock interfaces supported

Requirements

The library requires PHP 5.3 compiled with cURL extension (but you can override cURL dependencies).

Installation

  1. Install Composer:

    curl -sS https://getcomposer.org/installer | php
    
  2. Add the php-webmoney dependency:

    php composer.phar require baibaratsky/php-webmoney:0.10.*
    

Usage

There are more usage examples in the project wiki.

require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer

use baibaratsky\WebMoney;
use baibaratsky\WebMoney\Signer;

$webMoney = new WebMoney\WebMoney(new WebMoney\Request\Requester\CurlRequester);

$request = new WebMoney\Api\X\X9\Request;
$request->setSignerWmid('YOUR WMID');
$request->setRequestedWmid('REQUESTED WMID');

$request->sign(new Signer('YOUR WMID', 'FULL PATH TO KEY FILE', 'KEY FILE PASSWORD'));

if ($request->validate()) {
    /** @var WebMoney\Api\X\X9\Response $response */
    $response = $webMoney->request($request);

    if ($response->getReturnCode() === 0) {
        echo $response->getPurseByName('Z000000000000')->getAmount();
    }
}