2017 © Pedro PelĂĄez
 

library gpwebpay

GP WepPay payment gateway for a standard card payment

image

granam/gpwebpay

GP WepPay payment gateway for a standard card payment

  • Tuesday, July 10, 2018
  • by jaroslavtyc
  • Repository
  • 1 Watchers
  • 2 Stars
  • 663 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 37 Versions
  • 22 % Grown

The README.md

GPWebPay interface

Build Status Test Coverage Latest Stable Version License, (*1)

GPWebPay is a PHP library for online payments via GPWebPay service, (*2)

If you are using Nette framework, you may want Pixidos/GPWebPay Nette extension instead., (*3)

Quickstart

Set up & usage

 0) {
    try {
        $response = CardPayResponse::createFromArray($_POST, $settings, $digestSigner);
    } catch (GpWebPayErrorByCustomerResponse $gpWebPayErrorByCustomerResponse) {
        // some pretty error box for customer information about HIS mistake (for example "an invalid card number")
        /**
         * WARNING: do not rely blindly on this detection - for example if YOU (developer) are sending
         * card number in a hidden field, because the customer provided it to its account before and
         * does not need to enter it again, but the card number has been refused by GP WebPay,
         * you will show to the customer confusing message about an invalid card number,
         * although he does not enter it.
         * For full list of auto-detected customer mistakes @see GpWebPayErrorByCustomerResponse::isErrorCausedByCustomer
         */
        echo $gpWebPayErrorByCustomerResponse->getLocalizedMessage();
    } catch (GpWebPayErrorResponse $gpWebPayErrorResponse) {
        /* GP WebPay refuses request by YOUR (developer) mistake (for example "a duplicate order number")
         * - show an apology to the customer and log this, solve this */
    } catch (ResponseDigestCanNotBeVerified $responseDigestCanNotBeVerified) {
        /* values in response have been changed(!),
         * show an apology (or a warning?) to the customer and probably log this for an evidence */
    } catch (GpWebPayException $gpWebPayException) { // EVERY exception share this interface
        /* some generic error like "processing error on GP WebPay server",
         * show an apology to the customer and log this, solve this (or just try again later, it happens) */
    }
    /**
     * it is OK, lets process $response->getParametersForDigest();
     * @see \Granam\GpWebPay\CardPayResponse::getParametersForDigest
     */
} else { // REQUEST
    $currencyCodes = new CurrencyCodes(new IsoCurrencies());
    try {
        $cardPayRequestValues = CardPayRequestValues::createFromArray($_POST, $currencyCodes);
        $cardPayRequest = new CardPayRequest($cardPayRequestValues, $settings, $digestSigner);
    } catch (GpWebPayException $exception) {
        /* show an apology to the customer
         * (for example "we are sorry, our payment gateway is temporarily unavailable") and log it, solve it */
        exit(); // exit in the middle of a script is not a good idea - this is just a fast-and-dirty example
    } ?>
    <html>
    <body>
        <!-- some pretty recapitulation of the order -->
        <form method="post" action="<?= $cardPayRequest->getRequestUrl() ?>">
            <?php foreach ($cardPayRequest as $name => $value) {
                ?><input type="hidden" name="<?= $name ?>" value="<?= $value ?>"
            <?php } ?>
            <input type="submit" value="Confirm order">
       </form>
    </body>
    </html>

Troubleshooting

Almost all possible error cases covers clearly by many of exceptions, but some are so nasty that they can not be covered:, (*4)

  • after sending a request to GP WebPay you see just a logo and HTTP response code is 401
    • probably the URL for response you provided to GP WebPay in URL parameter is not valid in the point of view of GP WebPay
      • ensure that URL exists and there is NO redirection, like https://www.github.com to https://github.com/ with trailing slash (don't believe your eyes in a browser address bar, the trailing slash is often hidden there)

For tests against testing payment gateway you can use payment card, (*5)

  • Card number: 4056070000000008
  • Card validity: 12/2020
  • CVC2: 200
  • 3D Secure password: password

Installation

composer require granam/gpwebpay

Credits

This library originates from Pixidos/GPWebPay, which has same functionality, but can be used only as a Nette framework extension. All credits belong to the original author Ondra Votava from Pixidos., (*6)

Nevertheless, I am grateful to him for sharing that library publicly. Please more of such people!, (*7)

The Versions

10/07 2018
10/07 2018
27/02 2018

3.0.x-dev

3.0.9999999.9999999-dev https://github.com/jaroslavtyc/gpwebpay

GP WepPay payment gateway for a standard card payment

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by PIXDOS LTD

payment pay webpay checkout gp gp webpay

27/02 2018
27/02 2018
07/07 2017

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/jaroslavtyc/gpwebpay

GP WepPay payment gateway for a standard card payment

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by PIXDOS LTD

payment pay webpay checkout gp gp webpay

07/07 2017

2.0.x-dev

2.0.9999999.9999999-dev https://github.com/jaroslavtyc/gpwebpay

GP WepPay payment gateway for a standard card payment

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by PIXDOS LTD

payment pay webpay checkout gp gp webpay

07/07 2017
07/07 2017
14/03 2017
01/03 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
28/02 2017
27/02 2017
27/02 2017
27/02 2017
27/02 2017
27/02 2017
27/02 2017
27/02 2017
27/02 2017