2017 © Pedro Peláez
 

library epay

Library for epay.bg

image

wucdbm/epay

Library for epay.bg

  • Friday, August 25, 2017
  • by wucdbm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Epay

Usage, (*1)

  • Create a Wucdbm\Component\Epay\Client\ClientOptions instance, responsible for providing all the options the Wucdbm\Component\Epay\Client\Client needs. Its constructor needs the merchant ID and secret, provided by epay.bg. Remember to set the third constructor parameter to true or false depending on whether you're testing or not.
  • Create a handler that implements the Wucdbm\Component\Epay\Client\PaymentHandlerInterface interface. This interface has methods that are being called by the client
  • Create an instanceo of Wucdbm\Component\Epay\Client\Client, passing the above two
  • To create a payment form, call $client->getEpayForm($id, $amount, $description, $expiry, $formId, $okUrl, $cancelUrl)
  • To create an EasyPay payment ID, call $response = $this->client->getEasyPayIdn($id, $amount, $description, $expiry). This will return a Wucdbm\Component\Epay\Response\EasyPayResponse response. Call $response->getIdn() to get the ID. Beware, this method throws a Wucdbm\Component\Epay\Exception\EasyPayGetIdnError exception.

The WucdbmEpayBundle https://packagist.org/packages/wucdbm/epay-bundle uses this library, head there for more examples., (*2)

$options = new \Wucdbm\Component\Epay\Client\ClientOptions($merchantId, $merchantSecret, $isDebug);
// $options->set... to alter any options
$handler = new \My\Project\Payments\Epay\PaymentHandler(LogManager $some, PaymentManager $dependencies);
$client = new \Wucdbm\Component\Epay\Client\Client($options, $handler);

Getting a payment form is done like this, (*3)

$uniqId = uniqid(); // this is to make autosubmitting easy - $('#formId').submit();
$expiry = new \DateTime('today + 2 days');
// ... other parameters
$form = $client->getEpayForm($id, $amount, $description, $expiry, $formId, $okUrl, $cancelUrl);
// Display the form and optionally auto submit it. Another option is to alter the submit button through the options and let the user do that

Getting an EasyPay IDN, (*4)

$id = $payment->getId();
$amount = $payment->getAmount();
$description = 'Payment #' . $payment->getId();
$expiry = $payment->getExpiryDate();

try {
    $response = $this->client->getEasyPayIdn($id, $amount, $description, $expiry);
    $idn = $response->getIdn();
    // display idn to the user, do some logging.
    // the response body is available at $response->getBody();
    return $idn;
} catch (\Wucdbm\Component\Epay\Exception\EasyPayGetIdnError $ex) {
    $this->logEasyPayRequest($payment, $ex->getBody(), true);
    throw $ex;
}

Receiving payments, (*5)

$response = $client->receiveResponse($post);
// the client will call your handler, which must deal with the payments received
// $response is an \Wucdbm\Component\Epay\Response\ReceiveResponseInterface instance
// exceptions are caught internally and transformed into responses, the no data exception and checksum mismatch exceptions in particular generate a global error response for epay
echo $response->toString();
exit();
// alternatively, if you use Symfony's HttpFoundation component
$response = \Symfony\Component\HttpFoundation\Response($response->toString());

The Versions

25/08 2017

dev-master

9999999-dev

Library for epay.bg

  Sources   Download

GPL-2.0

The Requires

 

by Martin Kirilov

library epay wucdbm

25/08 2017

v1.0.2

1.0.2.0

Library for epay.bg

  Sources   Download

GPL-2.0

The Requires

 

by Martin Kirilov

library epay wucdbm

15/04 2016

v1.0.1

1.0.1.0

Library for epay.bg

  Sources   Download

GPL-2.0

The Requires

 

by Martin Kirilov

library epay wucdbm

05/04 2016

v1.0.0

1.0.0.0

Library for epay.bg

  Sources   Download

GPL-2.0

The Requires

 

by Martin Kirilov

library epay wucdbm

11/12 2015

v0.1.0

0.1.0.0

Library for epay.bg

  Sources   Download

GPL-2.0

The Requires

 

by Martin Kirilov

library epay wucdbm