TatraPay, CardPay - priame platby
Tvorba URL pre volanie portálu Tatrabanky (skrátené):
class tatrapay {
private function make_tatra_sign( $value ) {
// get the SHA1
$hash = substr( mhash ( MHASH_SHA1, $value ), 0, 8 );
$key = $this->KEY;
// encrypt hash with key
if( function_exists( 'mcrypt_module_open' ) ) {
// mcrypt 2.4.x
$td = mcrypt_module_open( MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "" );
$iv = mcrypt_create_iv( mcrypt_enc_get_iv_size ( $td ), MCRYPT_RAND );
mcrypt_generic_init( $td, $key, $iv );
$signature = strtoupper( bin2hex( mcrypt_generic ( $td, $hash ) ) );
mcrypt_generic_end( $td );
}
else {
// mcrypt 2.2.x
$signature = strtoupper( bin2hex( mcrypt_ecb ( MCRYPT_3DES, $key, $hash, MCRYPT_ENCRYPT ) ) );
}
return $signature;
}
function calculate_send_sign() {
// MID, AMT, CURR, VS, CS, RURL
$tosign = $this->MID;
$tosign .= $this->AMT;
$tosign .= $this->CURR;
$tosign .= $this->VS;
$tosign .= $this->CS;
$tosign .= $this->RURL;
return ( $this->make_tatra_sign( $tosign ) );
}
public function user_paymentUrl() {
$this->data = array();
// Make sign from url data
$sign = $this->calculate_send_sign();
// Link to online payment
$this->data['url'] = str_replace( '&', '&',
'https://moja.tatrabanka.sk/cgi-bin/e-commerce/start/e-commerce.jsp?'.
'PT='. urlencode( $this->PT ). // payment type
'&MID='. urlencode( $this->MID ). // merchant id
'&AMT='. urlencode( $this->AMT ). // order total price
'&CURR='. urlencode( $this->CURR ). // currency code
'&VS='. urlencode( $this->VS ). // order uid
'&CS='. urlencode( $this->CS ). // constant symbol
'&RURL='. urlencode( $this->RURL ). // merchant return url
'&IPC='. urlencode( $this->IPC ). // ip address, only for cardpay
'&NAME='. urlencode( $this->NAME ). // user name, only for cardpay
'&DESC='. urlencode( $this->DESC ). // payment description
'&SIGN='. $sign
);
return $this->data;
}
}
URL pre volanie CardPay (príklad)
https://moja.tatrabanka.sk/cgi-bin/e-commerce/start/e-commerce.jsp?
PT=CardPay&
MID=777&
AMT=640.00&
CURR=978&
VS=0000000192&
CS=0000000558&
RURL=http%3A%2F%2Fwww.tubby.sk%2Ftypo3conf%2Fredirect.php&
IPC=127.0.0.1&
NAME=robert+gonda&
DESC=Online_payment_tubby&
SIGN=BC5FB82B987AE239
Príklad volania triedy cardpay
require_once( 'cardpay.php' );
$payment = new user_payments_cardpay();
$payment->setAmt( number_format( $this->sum, 2, '.', '' ) ); // cena objednavky
$payment->setCurr( 'EUR' ); // mena
$payment->setVs( $this->objednavka_uid ); // cislo objednavky
$url = $payment->user_paymentUrl( $conf );
$out .= '<p><a href="'.$url['url'].'" title="cardpay"><strong>Priama platba...</strong></a></p>';
Kompletný kód dostupný len po prihlásení.
Generátor typoscriptu
Vytvára typoscript pre bežné použitie. Generátor je jednoduchý na obsluhu, stačí vyplniť zopár položiek formulára.