|
1 | 1 | # Borica
|
| 2 | + |
| 3 | +This is implementation of the BORICA API for adding payments with their service. |
| 4 | +EMV 3DS protocol. |
| 5 | + |
| 6 | +### Content |
| 7 | + |
| 8 | +* [Installetion](#) |
| 9 | +* [Configuration](#) |
| 10 | +* [Usage](#) |
| 11 | +* [Credit cards](#) |
| 12 | +* [Response codes ISO_8583](#) |
| 13 | +* [APGW response codes](#) |
| 14 | + |
| 15 | +### Installation |
| 16 | + |
| 17 | +Install using composer: |
| 18 | + |
| 19 | +```shell |
| 20 | +composer require vm-labs/borica |
| 21 | +``` |
| 22 | + |
| 23 | +### Configuration |
| 24 | + |
| 25 | +```yaml |
| 26 | + |
| 27 | +# config/packages/borica.yaml |
| 28 | + |
| 29 | +borica_api: |
| 30 | + test_url: # default https://3dsgate-dev.borica.bg/cgi-bin/cgi_link |
| 31 | + prod_url: # default https://3dsgate.borica.bg/cgi-bin/cgi_link |
| 32 | + |
| 33 | + profiles: |
| 34 | + config_1: |
| 35 | + terminal_id: # terminal id |
| 36 | + private_key: # path to private key |
| 37 | + private_key_password: # private key password |
| 38 | + public_key: # path to public key |
| 39 | + merchant: 1600000001 |
| 40 | + merchant_name: 'Payment' |
| 41 | + merchant_url: 'https://localhost' |
| 42 | + extended_mac: false # default true |
| 43 | + config_2: # optional |
| 44 | + terminal_id: # terminal id |
| 45 | + ... |
| 46 | + |
| 47 | +``` |
| 48 | + |
| 49 | +### Usage |
| 50 | + |
| 51 | +Currently possible requests are - payment, cancellation and status of transaction. |
| 52 | + |
| 53 | +The communication and transmission of parameters is done through HTML forms and HTTP post to the e-Commerce CGI server of BORICA. So with the current implementation you can check if the data is valid or take the form for a specific transaction. |
| 54 | + |
| 55 | + |
| 56 | +#### Payment request |
| 57 | + |
| 58 | +```php |
| 59 | + |
| 60 | +use Borica\Entity\Request as BoricaRequest; |
| 61 | +use Borica\Manager\RequestManager; |
| 62 | + |
| 63 | +class PaymentController extends AbstractController |
| 64 | +{ |
| 65 | + public function __invoke(RequestManager $requestManager) |
| 66 | + { |
| 67 | + $request = new BoricaRequest(); |
| 68 | + $request->setAmount(29); |
| 69 | + $request->setDescription('Payment details.'); |
| 70 | + |
| 71 | + # You can check that the data is valid or pick up the list of errors before submitting the form. |
| 72 | + if (!$paymentRequest->isValidData()) { |
| 73 | + $errorList = $paymentRequest->getErrorList(); |
| 74 | + // ... |
| 75 | + } |
| 76 | + |
| 77 | + $paymentRequest = $requestManager->payment($request, 'config_1'); // the second argument is required if you have more than one configuration |
| 78 | + |
| 79 | + return $this->render('payment-details.html.twig', [ |
| 80 | + 'form' => $paymentRequest->getForm()->createView(), |
| 81 | + ]); |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +``` |
| 86 | + |
| 87 | +#### Response |
| 88 | + |
| 89 | +```php |
| 90 | + |
| 91 | +use Borica\Manager\ResponseManager; |
| 92 | + |
| 93 | +class PaymentResponseController extends AbstractController |
| 94 | +{ |
| 95 | + public function __invoke(ResponseManager $responseManager) |
| 96 | + { |
| 97 | + $boricaResponse = $this->responseManager->response(); |
| 98 | + |
| 99 | + # Verification of the signature in response from APGW |
| 100 | + if (!$boricaResponse->isValid()) { |
| 101 | + // ... |
| 102 | + } |
| 103 | + |
| 104 | + # Check if the borica response is completed successfully. |
| 105 | + if (!$boricaResponse->isSuccessful()) { |
| 106 | + $responseCode = $boricaResponse->getResponseCode(); |
| 107 | + // ... |
| 108 | + } |
| 109 | + |
| 110 | + $response = $boricaResponse->getData(); |
| 111 | + $orderId = $response->getOrderId(); |
| 112 | + // ... |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +``` |
| 117 | + |
| 118 | +#### Status |
| 119 | + |
| 120 | +```php |
| 121 | + |
| 122 | +use Borica\Entity\Request as BoricaRequest; |
| 123 | +use Borica\Manager\RequestManager; |
| 124 | + |
| 125 | +class StatusRequestController extends AbstractController |
| 126 | +{ |
| 127 | + public function __invoke(RequestManager $requestManager) |
| 128 | + { |
| 129 | + $request = new BoricaRequest(); |
| 130 | + $request->setOrder($order); |
| 131 | + |
| 132 | + $statusRequest = $requestManager->status($request); |
| 133 | + |
| 134 | + if (!$paymentRequest->isValidData()) { |
| 135 | + $errorList = $paymentRequest()->getErrorList(); |
| 136 | + // ... |
| 137 | + } |
| 138 | + |
| 139 | + $boricaResponse = $statusRequest->request(); |
| 140 | + |
| 141 | + if ($boricaResponse->isValid()) { |
| 142 | + // ... |
| 143 | + } |
| 144 | + |
| 145 | + if ($boricaResponse->isSuccessful()) { |
| 146 | + // ... |
| 147 | + } |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +``` |
| 152 | + |
| 153 | +### Credit cards |
| 154 | + |
| 155 | + Card number | Response code | 3DS password |
| 156 | +------------------|:--------------------:|-------------: |
| 157 | + 5100770000000022 | **00** | - |
| 158 | + 4341792000000044 | **00** | 111111 |
| 159 | + 5555000000070019 | **04** | - |
| 160 | + 5555000000070027 | **13** | - |
| 161 | + 5555000000070035 | **91** | - |
| 162 | + 4010119999999897 | **amount dependant** | - |
| 163 | + 5100789999999895 | **amount dependant** | 111111 |
| 164 | + |
| 165 | +##### Amount dependant |
| 166 | + |
| 167 | + Amount | Response code | Description |
| 168 | +--------------------:|:-------------:|------------- |
| 169 | + 1,00 - 1,99 | **01** | Refer to card issuer |
| 170 | + 2,00 - 2,99 | **04** | Pick up |
| 171 | + 3,00 - 3,99 | **05** | Do not honour |
| 172 | + 4,00 - 4,99 | **13** | Invalid amount |
| 173 | + 5,00 - 5,99 | **30** | Format error |
| 174 | + 6,00 - 6,99 | **91** | Issuer or switch is inoperative |
| 175 | + 7,00 - 7,99 | **96** | System Malfunction |
| 176 | + 8,00 - 8,99 | **-** | Timeout |
| 177 | + 30,00 - 40,00 | **01** | Refer to card issuer |
| 178 | + 50,00 - 70,00 | **04** | Pick up |
| 179 | + 80,00 - 90,00 | **05** | Do not Honour |
| 180 | + 100,00 - 110,00 | **13** | Invalid amount |
| 181 | + 120,00 - 130,00 | **30** | Format error |
| 182 | + 140,00 - 150,00 | **91** | Issuer or switch is inoperative |
| 183 | + 160,00 - 170,00 | **96** | System Malfunction |
| 184 | + 180,00 - 190,00 | **-** | Timeout |
| 185 | + 10000,65 - 10000,65 | **65/1A** | Soft Decline |
| 186 | + |
| 187 | +### Response codes |
| 188 | +###### [ISO_8583](https://en.wikipedia.org/wiki/ISO_8583) |
| 189 | + |
| 190 | + Response Code | Description |
| 191 | +:-------------:|------------- |
| 192 | + **00** | Successfully completed |
| 193 | + **01** | Refer to card issuer |
| 194 | + **04** | Pick Up |
| 195 | + **05** | Do not Honour |
| 196 | + **06** | Error |
| 197 | + **12** | Invalid transaction |
| 198 | + **13** | Invalid amount |
| 199 | + **14** | No such card |
| 200 | + **15** | No such issuer |
| 201 | + **17** | Customer cancellation |
| 202 | + **30** | Format error |
| 203 | + **35** | Pick up, card acception contact acquirer |
| 204 | + **36** | Pick up, card restricted |
| 205 | + **37** | Pick up, call acquirer security |
| 206 | + **38** | Pick up, allowable PIN tries exceeded |
| 207 | + **39** | No credit account |
| 208 | + **40** | Requested function not supported |
| 209 | + **41** | Pick up, lost card |
| 210 | + **42** | No universal account |
| 211 | + **43** | Pick up, stolen card |
| 212 | + **54** | Expired card / target |
| 213 | + **55** | Incorrect PIN |
| 214 | + **56** | No card record |
| 215 | + **57** | Transaction not permitted to cardholder |
| 216 | + **58** | Transaction not permitted to terminal |
| 217 | + **59** | Suspected fraud |
| 218 | + **85** | No reason to decline |
| 219 | + **88** | Cryptographic failure |
| 220 | + **89** | Authentication failure |
| 221 | + **91** | Issuer or switch is inoperative |
| 222 | + **95** | Reconscile error / auth not found |
| 223 | + **96** | System malfunction |
| 224 | + |
| 225 | +### APGW response codes |
| 226 | + |
| 227 | + Response Code | Descriptioin |
| 228 | +:-------------:|-------------- |
| 229 | + **-1** | A mandatory request field is not filled in |
| 230 | + **-2** | CGI request validation failed |
| 231 | + **-3** | Acquirer host (TS) does not respond or wrong format of e-gateway response template file |
| 232 | + **-4** | No connection to the acquirer host (TS) |
| 233 | + **-5** | The acquirer host (TS) connection failed during transaction processing |
| 234 | + **-6** | e-Gateway configuration error |
| 235 | + **-7** | The acquirer host (TS) response is invalid, e.g. mandatory fields missing |
| 236 | + **-8** | Error in the "Card number" request field |
| 237 | + **-9** | Error in the "Card expiration date" request field |
| 238 | + **-10** | Error in the "Amount" request field |
| 239 | + **-11** | Error in the "Currency" request field |
| 240 | + **-12** | Error in the "Merchant ID" request field |
| 241 | + **-13** | The referrer IP address (usually the merchant's IP) is not the one expected |
| 242 | + **-14** | No connection to the internet terminal PIN pad or agent program is not running on the internet terminal computer/workstation |
| 243 | + **-15** | Error in the "RRN" request field |
| 244 | + **-16** | Another transaction is being performed on the terminal |
| 245 | + **-17** | The terminal is denied access to e-Gateway |
| 246 | + **-18** | Error in the CVC2 or CVC2 Description request fields |
| 247 | + **-19** | Error in the authentication information request or authentication failed |
| 248 | + **-20** | The permitted time interval (1 hour by default) between the transaction timestamp request field and the e-Gateway time was exceeded |
| 249 | + **-21** | The transaction has already been executed |
| 250 | + **-22** | Transaction contains invalid authentication information |
| 251 | + **-23** | Invalid transaction context |
| 252 | + **-24** | Transaction context data mismatch |
| 253 | + **-25** | Transaction canceled (e.g. by user) |
| 254 | + **-26** | Invalid action BIN |
| 255 | + **-27** | Invalid merchant name |
| 256 | + **-28** | Invalid incoming addendum(s) |
| 257 | + **-29** | Invalid/duplicate authentication reference |
| 258 | + **-30** | Transaction was declined as fraud |
| 259 | + **-31** | Transaction already in progress |
| 260 | + **-32** | Duplicate declined transaction |
| 261 | + **-33** | Customer authentication by random amount or verify one-time code in progress |
| 262 | + **-34** | Mastercard Installment customer choice in progress |
| 263 | + **-35** | Mastercard Installments auto canceled |
| 264 | + **-36** | Mastercard Installment user canceled |
0 commit comments