2017 © Pedro Peláez
 

library w1-api

W1 API

image

and/w1-api

W1 API

  • Sunday, January 18, 2015
  • by And
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

W1 API helper

The workflow constists from 2 steps:, (*1)

  1. Redirect user to W1 payment page
  2. Check the payment

Here is code samples for each step:, (*2)

1-st step:, (*3)

$api = new W1\PaymentAPI('merchantId', 'secretKey');
echo $api->getFormHTMLDocument($api->createPaymentForm()
    ->setPaymentId(uniqid())
    ->setCultureId('ru' == $this->getLastLocale() ? 
      W1\Form\PaymentForm::LANG_RU : 
      W1\Form\PaymentForm::LANG_EN
     )
    ->setAmount(2.99)
    ->setCurrencyId(W1\Form\PaymentForm::CURRENCY_USD)
    ->setDescription('Оплата за что-то')
    ->setSuccessUrl($this->get_page_url('buy_method_w1_callback')) // to redirect user
    ->setFailUrl($this->get_page_url('')) // to redirect user

2-nd step:, (*4)

$api = new W1\PaymentAPI('merchantId', 'secretKey');
if (!empty($_POST))
{
    if (!$api->createPaymentForm()->isPaymentAccepted($_POST))
    {
        $this->logger()->log_exception('Error:W1', 'Wrong confirmation: ' . json_encode($_POST), __FILE__, __LINE__);
        echo $api->getRetryResponse('Wrong confirmation');
    }
    else
    {
        $this->buy_dlc_finalize();
        echo $api->getSuccessResponse();
    }
}
else $this->redirect_to_relative('buy_method_w1');

And that's all! You're wonderful! :), (*5)

The Versions

18/01 2015

dev-master

9999999-dev https://github.com/logical-and/w1-api

W1 API

  Sources   Download

BSD-2-Clause

The Requires

 

by Avatar And

api payment w1

18/01 2015

v0.5

0.5.0.0 https://github.com/logical-and/w1-api

W1 API

  Sources   Download

BSD-2-Clause

The Requires

 

by Avatar And

api payment w1