Giter Club home page Giter Club logo

tbcardpay's Introduction

TbCardPay - minimalist C# Tatrabanka CardPay implementation (HMAC SHA256)

version 0.2.0 (2015-08-03)
(c) 2014 Dušan Hlavatý ([email protected])
freely distributable under The MIT License (MIT)
https://github.com/dhlavaty/TbCardPay

Purpose (EN):

Minimalist (single file, single class, no external dependencies) implementation of Tatrabanka CardPay (HMAC SHA256 version) payment gateway written in C#. No dependencies. Contains self-test (poor-mans unit test) to ensure correct implementation.

Popis (SK):

Minimalistická (iba jeden súbor, jedna trieda, žiadne externé závislosti ani knižnice) implementácia platobného systému Tatrabanka CardPay (verzia HMAC SHA256). Obsahuje self-test, ktorý zaručuje správnu implementáciu hash algoritmov.

Setup / Nastavenie:

(web.config - replace values with ones received from Tatrabanka)

<add key="CardPay:Mid" value="9999" />
<add key="CardPay:HexEncryptKey" value="1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D1A2B3C4D" />
<add key="CardPay:FormActionUrl" value="https://moja.tatrabanka.sk/cgi-bin/e-commerce/start/cardpay" />

Usage / Použitie:

Payment request / Žiadosť o platbu

// initialize your.cs file
TbCardPay cardPay = TbCardPay.CreateRequest(132.15,
                                            TbCardPay.Currency.EUR,
                                            1234567890, 
                                            "http://my.eshop.com/CardPayReturnAddress", 
                                            "123.123.123.123", 
                                            "Jan Pal");
                                            
                                            
<!-- your view or html file - assume that 'cardPay' is inicialized TbCardPay instance, see above -->
<form action="@cardPay.FormActionUrl" method="post">
    @Html.Raw(cardPay.HtmlHiddenFields())
    
    <button type="submit">Pay</button>
</form>

Payment response / Odpoveď z banky

// MVC example
public virtual ActionResult CardPayResponse(string amt, string curr, int vs, string res, string ac, string tid, string timestamp, string hmac)
{
    if (false == TbCardPay.CheckBankResponse(amt, curr, vs, res, ac, tid, timestamp, hmac))
    {
        // SIGN from bank is NOT valid - log this error and exit
        return new HttpNotFoundResult();
    }

    if (res == "OK")
    {
        // ... payment was OK, you can pair your payments using "vs" parameter
    } else {
        // ... payment has failed (maybe credit card was expired)
    }
}

Self-test (EN)

It is not necessary to run self-test, it is run automatically. But you can:

TbCardPay.SelfTest();

Self-test (SK)

Self-test nie je potrebné spúšťať manuláne, spúšťa sa automaticky. No ak chcete, môžete takto:

TbCardPay.SelfTest();

Changelog:

  • 2015-08-03 ver 0.2.0

    • changed to HMAC SHA256 version
  • 2014-04-10 ver 0.1.0

    • initial release

tbcardpay's People

Contributors

dhlavaty avatar

Stargazers

Noro Korny avatar  avatar

Watchers

 avatar  avatar

Forkers

roman3x

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.