veneliniliev / borica-3ds
Borica 3DS payments gateway
Installs: 10 407
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 7
Forks: 4
Open Issues: 0
Requires
- php: >=5.6
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- myclabs/php-enum: ^1.0
Requires (Dev)
- phpunit/phpunit: >=5
- squizlabs/php_codesniffer: ^3.5
- victorjonsson/markdowndocs: ^1.3
This package is auto-updated.
Last update: 2024-11-14 12:31:10 UTC
README
Requirements
- PHP >= 5.6 (including 8.2)
- ext-mbstring
- ext-openssl
- ext-curl
- ext-json
Installation
composer require veneliniliev/borica-3ds
For more methods, read api documentation.
Certificates
Generate private key
# Production key openssl genrsa -out production.key -aes256 2048 # Development key openssl genrsa -out development.key -aes256 2048
Generate CSR
IMPORTANT: in Organizational Unit Name (eg, section)
enter your terminal ID and
in Common Name (eg, fully qualified host name)
enter your domain name.
# Production csr openssl req -new -key production.key -out VNNNNNNN_YYYYMMDD_P.csr # Development csr openssl req -new -key development.key -out VNNNNNNN_YYYYMMDD_D.csr
Имената на файловете се създават по следната конвенция: VNNNNNNN_YYYYMMDD_T, където:
- VNNNNNNN – TID на терминала, предоставен от Финансовата Институция
- YYYYMMDD – дата на заявка
- T – тип на искания сертификат, значения – D – за development среда, Р – за продукционна среда
Usage
IMPORTANT: Switch signing schema MAC_EXTENDED / MAC_ADVANCED / MAC_GENERAL with methods:
$saleRequest->setSigningSchemaMacGeneral(); // use MAC_GENERAL $saleRequest->setSigningSchemaMacExtended(); // use MAC_EXTENDED $saleRequest->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED
Default signing schema is MAC_GENERAL!
Sale request
use VenelinIliev\Borica3ds\SaleRequest; // ... $saleRequest = (new SaleRequest()) ->setAmount(123.32) ->setOrder(123456) ->setDescription('test') ->setMerchantUrl('https://test.com') // optional ->setBackRefUrl('https://test.com/back-ref-url') // optional / required for development ->setTerminalID('<TID - V*******>') ->setMerchantId('<MID - 15 chars>') ->setPrivateKey('\<path to certificate.key>', '<password / or use method from bottom>') ->setMInfo(array( // Mandatory cardholderName and ( email or MobilePhone ) 'email'=>'user@sample.com', 'cardholderName'=>'CARDHOLDER NAME', // Max 45 chars 'mobilePhone'=> array( 'cc'=>'359', // Country code 'subscriber'=>'8939999888', // Subscriber number ), 'threeDSRequestorChallengeInd'=>'04', // Optional for Additional Authentication )) //->setSigningSchemaMacGeneral(); // use MAC_GENERAL //->setSigningSchemaMacExtended(); // use MAC_EXTENDED //->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED ->setPrivateKeyPassword('test'); $formHtml = $saleRequest->generateForm(); // only generate hidden html form with filled inputs // OR $saleRequest->send(); // generate and send form with js
Sale response
Catch response from borica on BACKREF
url ($saleRequest->setBackRefUrl('<url>'))
use VenelinIliev\Borica3ds\SaleResponse; // .... $isSuccessfulPayment = (new SaleResponse()) ->setPublicKey('<path to public certificate.cer>') ->setResponseData($_POST) //Set POST data from borica response //->setSigningSchemaMacGeneral(); // use MAC_GENERAL //->setSigningSchemaMacExtended(); // use MAC_EXTENDED //->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED ->isSuccessful();
Get response code
use VenelinIliev\Borica3ds\SaleResponse; // ... $saleResponse= (new SaleResponse()) ->setPublicKey('<path to public certificate.cer>') //->setSigningSchemaMacGeneral(); // use MAC_GENERAL //->setSigningSchemaMacExtended(); // use MAC_EXTENDED //->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED // ... // automatic fill data from $_POST or can be set by ->setResponseData(<array>) // ... $saleResponse->getResponseCode(); // return RC from response $saleResponse->getVerifiedData('<key from post request ex: RC>'); // return verified data from post by key $saleResponse->isSuccessful(); // RC === 00 and data is verified
Response codes table
Transaction status check
use VenelinIliev\Borica3ds\Enums\TransactionType; use VenelinIliev\Borica3ds\StatusCheckRequest; // ... $statusCheckRequest = (new StatusCheckRequest()) //->inDevelopment() ->setPrivateKey('\<path to certificate.key>', '<password / or use method from bottom>') ->setPublicKey('<path to public certificate.cer>') ->setTerminalID('<TID - V*******>') ->setOrder('<order>') ->setOriginalTransactionType(TransactionType::SALE()) // transaction type //->setSigningSchemaMacGeneral(); // use MAC_GENERAL //->setSigningSchemaMacExtended(); // use MAC_EXTENDED //->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED //send to borica $statusCheckResponse = $statusCheckRequest->send(); // get data from borica response $verifiedResponseData = $statusCheckResponse->getResponseData(); // get field from borica response $statusCheckResponse->getVerifiedData('<field from response. ex: ACTION');
Reversal request
use VenelinIliev\Borica3ds\ReversalRequest; // ... $reversalRequest = (new ReversalRequest()) //->inDevelopment() ->setPrivateKey('\<path to certificate.key>', '<password / or use method from bottom>') ->setPublicKey('<path to public certificate.cer>') ->setTerminalID('<TID - V*******>') ->setAmount(123.32) ->setOrder(123456) ->setDescription('test reversal') ->setMerchantId('<MID - 15 chars>') ->setRrn('<RRN - Original transaction reference (From the sale response data)>') ->setIntRef('<INT_REF - Internal reference (From the sale response data)>') //->setSigningSchemaMacGeneral(); // use MAC_GENERAL //->setSigningSchemaMacExtended(); // use MAC_EXTENDED //->setSigningSchemaMacAdvanced(); // use MAC_ADVANCED //send reversal request to borica $reversalRequestResponse = $reversalRequest->send(); // get data from borica reversal response $verifiedResponseData = $reversalRequestResponse->getResponseData(); // get field from borica reversal response $reversalRequestResponse->getVerifiedData('STATUSMSG');
Methods
Set environments
Default environment is production!
$saleRequest->setEnvironment(true); // set to production $saleRequest->setEnvironment(false); // set to development $saleRequest->inDevelopment(); // set to development $saleRequest->inProduction(); // set to production $saleRequest->isProduction(); // check is production environment? $saleRequest->isDevelopment(); // check is development environment?
Credit cards for testing
Cards
Карти, за които се получава съответен резултат при транзакция според сумата
Todo
- laravel integration