/** * Retorna un array amb tots els valors per carregar al TPV * * @param DOUBLE $PREU * @param STRING $NOM * @return ARRAY */ static function getTPV($PREU, $NOM, $matricula, $idS, $WEB = true, $entrades = false) { $TPV = array(); $TPV['Ds_Merchant_Amount'] = $PREU * 100; $TPV['Ds_Merchant_Currency'] = '978'; $TPV['Ds_Merchant_Order'] = $matricula; $TPV['Ds_Merchant_MerchantCode'] = OptionsPeer::getString('TPV_Ds_Merchant_MerchantCode', $idS); $TPV['Ds_Merchant_Terminal'] = '1'; $TPV['Ds_Merchant_TransactionType'] = '0'; if ($WEB) { if ($entrades) { $TPV['Ds_Merchant_MerchantURL'] = OptionsPeer::getString('TPV_WEB_ENT_Merchant_MerchantURL', $idS); $TPV['Ds_Merchant_UrlOK'] = OptionsPeer::getString('TPV_WEB_ENT_Ds_Merchant_UrlOK', $idS); $TPV['Ds_Merchant_UrlKO'] = OptionsPeer::getString('TPV_WEB_ENT_Ds_Merchant_UrlKO', $idS); } else { $TPV['Ds_Merchant_MerchantURL'] = OptionsPeer::getString('TPV_WEB_Merchant_MerchantURL', $idS); $TPV['Ds_Merchant_UrlOK'] = OptionsPeer::getString('TPV_WEB_Ds_Merchant_UrlOK', $idS); $TPV['Ds_Merchant_UrlKO'] = OptionsPeer::getString('TPV_WEB_Ds_Merchant_UrlKO', $idS); } } else { if ($entrades) { $TPV['Ds_Merchant_MerchantURL'] = OptionsPeer::getString('TPV_ENT_Merchant_MerchantURL', $idS); $TPV['Ds_Merchant_UrlOK'] = OptionsPeer::getString('TPV_ENT_Ds_Merchant_UrlOK', $idS); $TPV['Ds_Merchant_UrlKO'] = OptionsPeer::getString('TPV_ENT_Ds_Merchant_UrlKO', $idS); } else { $TPV['Ds_Merchant_MerchantURL'] = OptionsPeer::getString('TPV_Merchant_MerchantURL', $idS); $TPV['Ds_Merchant_UrlOK'] = OptionsPeer::getString('TPV_Ds_Merchant_UrlOK', $idS); $TPV['Ds_Merchant_UrlKO'] = OptionsPeer::getString('TPV_Ds_Merchant_UrlKO', $idS); } } $TPV['Ds_Merchant_ProductDescription'] = OptionsPeer::getString('TPV_ProductDescription', $idS); $TPV['Ds_Merchant_Titular'] = $NOM; $TPV['Ds_Merchant_MerchantName'] = OptionsPeer::getString('TPV_MerchantName', $idS); $TPV['Ds_Merchant_MerchantData'] = $matricula; /* if($idS == 0){ $message = $TPV['Ds_Merchant_Amount']. $TPV['Ds_Merchant_Order']. $TPV['Ds_Merchant_MerchantCode']. $TPV['Ds_Merchant_Currency']. OptionsPeer::getString('TPV_PASSWORD',$idS); } else { $message = $TPV['Ds_Merchant_Amount']. $TPV['Ds_Merchant_Order']. $TPV['Ds_Merchant_MerchantCode']. $TPV['Ds_Merchant_Currency']. $TPV['Ds_Merchant_TransactionType']. $TPV['Ds_Merchant_MerchantURL']. OptionsPeer::getString('TPV_PASSWORD',$idS); } */ //Preparem dades per enviar i signar $RedSys = new sha256(); $RedSys->setParameter('Ds_Merchant_Amount', $TPV['Ds_Merchant_Amount']); $RedSys->setParameter('Ds_Merchant_Order', $TPV['Ds_Merchant_Order']); $RedSys->setParameter('Ds_Merchant_MerchantCode', $TPV['Ds_Merchant_MerchantCode']); $RedSys->setParameter('Ds_Merchant_Currency', $TPV['Ds_Merchant_Currency']); $RedSys->setParameter('Ds_Merchant_TransactionType', $TPV['Ds_Merchant_TransactionType']); $RedSys->setParameter('Ds_Merchant_Terminal', $TPV['Ds_Merchant_Terminal']); $RedSys->setParameter('Ds_Merchant_MerchantURL', $TPV['Ds_Merchant_MerchantURL']); $RedSys->setParameter('Ds_Merchant_UrlOK', $TPV['Ds_Merchant_UrlOK']); $RedSys->setParameter('Ds_Merchant_UrlKO', $TPV['Ds_Merchant_UrlKO']); $RedSys->setParameter('Ds_Merchant_ProductDescription', $TPV['Ds_Merchant_ProductDescription']); $RedSys->setParameter('Ds_Merchant_Titular', $TPV['Ds_Merchant_Titular']); $RedSys->setParameter('Ds_Merchant_MerchantName', $TPV['Ds_Merchant_MerchantName']); $RedSys->setParameter('Ds_Merchant_MerchantData', $TPV['Ds_Merchant_MerchantData']); //Buidem les dades i omplim amb el nou format SHA256 $TPV = array(); $TPV['Ds_SignatureVersion'] = 'HMAC_SHA256_V1'; $TPV['Ds_MerchantParameters'] = $RedSys->createMerchantParameters(); $TPV['Ds_Signature'] = $RedSys->createMerchantSignature(OptionsPeer::getString('TPV_PASSWORD', $idS)); return $TPV; }