Code Monkey home page Code Monkey logo

banklink's Introduction

Build Status Coverage Status Test Status Codacy Badge Latest Stable Version Total Downloads License SensioLabsInsight

PHP Payment library

PHP payment library to easily integrate Baltic banklinks, E-commerce gateaway (Estcard, Nets Estonia) and Liizi Payment Link.

View API documentation at http://renekorss.github.io/Banklink/

Composer

composer require renekorss/Banklink

Supported providers

Provider Payment Authentication
Danskebank
Krediidipank
LHV
SEB
Swedbank
Nordea
Estcard does not apply
Liisi Payment Link does not apply

How to use?

SECURITY WARNING

Never keep your private and public keys in publicly accessible folder. Instead place keys under root folder (usually public_html or www).

If you store keys as strings in database, then they should be accessible only over HTTPS protocol.

Payment

<?php
    require __DIR__ . '/vendor/autoload.php';

    use RKD\Banklink;

    // Init protocol
    $protocol = new Banklink\Protocol\IPizza(
        'uid100010', // seller ID (VK_SND_ID)
        __DIR__ . '/../keys/seb_user_key.pem', // private key
        '', // private key password, leave empty, if not needed
        __DIR__ . '/../keys/seb_bank_cert.pem', // public key
        'http://localhost/banklink/SEB.php' // return url
    );

    // Init banklink
    $seb = new Banklink\SEB($protocol);

    // Set payment data and get payment request object
    // orderId, sum, message, language
    $request = $seb->getPaymentRequest(123453, 150, 'Test makse', 'EST');
?>

<form method="POST" action="<?php echo $request->getRequestUrl(); ?>">
  <?php echo $request->getRequestInputs(); ?>
  <input type="submit" value="Pay with SEB!" />
</form>

Authentication

<?php
    require __DIR__ . '/vendor/autoload.php';

    use RKD\Banklink;

    // Init protocol
    $protocol = new Banklink\Protocol\IPizza(
        'uid100010', // seller ID (SND ID)
        __DIR__ . '/../keys/seb_user_key.pem', // private key
        '', // private key password, leave empty, if not needed
        __DIR__ . '/../keys/seb_bank_cert.pem', // public key
        'http://localhost/banklink/SEB.php' // return url
    );

    // Init banklink
    $seb = new Banklink\SEB($protocol);

    // Get auth request object
    $request = $seb->getAuthRequest();
?>

<form method="POST" action="<?php echo $request->getRequestUrl(); ?>">
  <?php echo $request->getRequestInputs(); ?>
  <input type="submit" value="Authenticate with SEB!" />
</form>

Response from provider

<?php
    require __DIR__ . '/vendor/autoload.php';

    use RKD\Banklink;

    // Init protocol
    $protocol = new Banklink\Protocol\IPizza(
        'uid100010', // seller ID (SND ID)
        __DIR__ . '/../keys/seb_user_key.pem', // private key
        '', // private key password, leave empty, if not needed
        __DIR__ . '/../keys/seb_bank_cert.pem', // public key
        'http://localhost/banklink/SEB.php' // return url
    );

    // Init banklink
    $seb = new Banklink\SEB($protocol);

    // Get response object
    $response = $seb->handleResponse($_POST);

    // Successful
    if ($response->wasSuccessful()) {
      // Get whole array of response
      $responseData    = $response->getResponseData();

      // User prefered language
      $language        = $response->getLanguage();

      // Only for payment data
      $orderId         = $response->getOrderId();
      $sum             = $response->getSum();
      $currency        = $response->getCurrency();
      $sender          = $response->getSender();
      $transactionId   = $response->getTransactionId();
      $transactionDate = $response->getTransactionDate();

      // Only for auth data
      $userId          = $response->getUserId(); // Person ID
      $userName        = $response->getUserName(); // Person name
      $country         = $response->getUserCountry(); // Person country
      $authDate        = $response->getAuthDate(); // Authentication response datetime

      // Method used for authentication
      // Possible values: ID Card, Mobile ID, One-off code card, PIN-calculator, Code card or unknown
      $authMethod      = $response->getAuthMethod();

    // Failed
    } else {
      // Payment data
      $orderId         = $response->getOrderId(); // Order id to cancel order etc.
    }
?>

Tasks

  • composer tests - run tests
  • composer docs - build API documentation
  • composer phpmd - run PHP Mess Detector
  • composer phpcs - run PHP CodeSniffer

Testing your banklink

You can test your banklink with pangalink.net application (Windows, Mac, Linux).

License

Licensed under MIT

banklink's People

Contributors

lenar avatar renekorss avatar

Watchers

 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.