GithubHelp home page GithubHelp logo

php-webmoney's Introduction

WebMoney API PHP Library

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

  • X1: sending invoice from merchant to customer
  • X2: transferring funds from one purse to another
  • X3: transactions history, checking transactions status
  • X4: issued invoices history, verifying whether the invoices were paid
  • X5: completing a code-protected transaction
  • 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
  • X13: recalling incomplete protected transaction
  • X14: fee-free refund
  • X15: trust management
  • X17: operations with arbitration contracts
  • X18: getting transaction details via merchant.webmoney
  • X19: verifying personal information for the owner of a WM identifier
  • X21: setting trust for merchant payments by SMS
  • X22: receiving the ticket of prerequest payment form at merchant.webmoney

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.14.*
    

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\Api\X\X9\Request;
use baibaratsky\WebMoney\Api\X\X9\Response;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Signer;

// If you don’t want to use the WM root certificate to protect against DNS spoofing, pass false to the CurlRequester constructor
$webMoney = new WebMoney\WebMoney(new CurlRequester);

$request = new Request;
$request->setSignerWmid('YOUR WMID');
$request->setRequestedWmid('REQUESTED WMID');

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

// You can access the request XML: $request->getData()

if ($request->validate()) {
    /** @var Response $response */
    $response = $webMoney->request($request);

    // The response from WebMoney is here: $response->getRawData()

    if ($response->getReturnCode() === 0) {
        echo $response->getPurseByName('Z000000000000')->getAmount();
    } else {
        echo 'Error: ' . $response->getReturnDescription();
    }
}

Authentication with a Light certificate

In case of authentication with a Light certificate, pass Request::AUTH_LIGHT to the request constructor and use cert() instead of sign().

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

use baibaratsky\WebMoney;
use baibaratsky\WebMoney\Api\X\X9\Request;
use baibaratsky\WebMoney\Api\X\X9\Response;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;

// If you don’t want to use the WM root certificate to protect against DNS spoofing, pass false to the CurlRequester constructor
$webMoney = new WebMoney\WebMoney(new CurlRequester);

$request = new Request(Request::AUTH_LIGHT);
$request->setRequestedWmid('REQUESTED WMID');

$request->cert('FULL PATH TO THE CERTIFICATE FILE', 'FULL PATH TO THE CERTIFICATE KEY');

// You can access the request XML: $request->getData()

if ($request->validate()) {
    /** @var Response $response */
    $response = $webMoney->request($request);

    // The response from WebMoney is here: $response->getRawData()

    if ($response->getReturnCode() === 0) {
        echo $response->getPurseByName('Z000000000000')->getAmount();
    } else {
        echo 'Error: ' . $response->getReturnDescription();
    }
}

php-webmoney's People

Contributors

baibaratsky avatar chuprik avatar grandmotivator avatar mitalcoi avatar roman-rybalko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.