├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── composer.json
├── phpunit.xml.dist
├── src
├── Gateway.php
└── Message
│ ├── AuthorizeRequest.php
│ ├── CaptureRequest.php
│ ├── PurchaseRequest.php
│ ├── RefundRequest.php
│ ├── Response.php
│ ├── VoidRequest.php
│ └── bkm
│ ├── BkmExpressPaymentService.wsdl
│ ├── BkmExpressPaymentService.xsd
│ ├── RequestMerchInfoService_clear.wsdl
│ ├── RequestMerchInfoService_latest.wsdl
│ ├── RequestMerchInfoService_latest.xsd
│ ├── bkm.pem
│ ├── bkm.pub
│ ├── bkm_client_sign_certificate_test.pem
│ └── bkm_client_sign_certificate_test.pub
└── tests
├── GatewayTest.php
├── Message
├── RefundRequestTest.php
└── ResponseTest.php
└── Mock
├── PurchaseFailure.txt
├── PurchaseFailureWithoutStatusCode.txt
├── PurchaseRedirect.txt
└── PurchaseSuccess.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /nbproject
3 | composer.lock
4 | composer.phar
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | * Fork the project.
4 | * Make your feature addition or bug fix.
5 | * Add tests for it. This is important so I don't break it in a future version unintentionally.
6 | * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files.
7 | * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
8 | style and that all tests pass.
9 | * Send the pull request.
10 | * Check that the Travis CI build passed. If not, rinse and repeat.
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012-2015 Yasin Kuyu
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Omnipay: BKM Express (BETA)
2 |
3 | **BKM Express gateway for Omnipay payment processing library**
4 |
5 | [](https://packagist.org/packages/yasinkuyu/omnipay-bkm)
6 | [](https://packagist.org/packages/yasinkuyu/omnipay-bkm)
7 | [](https://packagist.org/packages/yasinkuyu/omnipay-bkm)
8 | [](https://packagist.org/packages/yasinkuyu/omnipay-bkm)
9 |
10 | [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
11 | processing library for PHP 5.3+. This package implements BKM Express (Turkish Payment Gateways) support for Omnipay.
12 |
13 | BKM Express sanal pos hizmeti için omnipay kütüphanesi.
14 |
15 | ## Installation
16 |
17 | Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
18 | to your `composer.json` file:
19 |
20 | ```json
21 | {
22 | "require": {
23 | "yasinkuyu/omnipay-bkm": "~2.0"
24 | }
25 | }
26 | ```
27 |
28 | And run composer to update your dependencies:
29 |
30 | $ curl -s http://getcomposer.org/installer | php
31 | $ php composer.phar update
32 |
33 | ## Basic Usage
34 |
35 | The following gateways are provided by this package:
36 |
37 | * BKM Express
38 |
39 | Gateway Methods
40 |
41 | * purchase($options) - authorize and immediately capture an amount on the customer's card
42 | * refund($options) - refund an already processed transaction
43 |
44 | For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
45 | repository.
46 |
47 | ## Unit Tests
48 |
49 | PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
50 |
51 | ## Sample App
52 |
53 | setBank("akbank");
64 | $gateway->setMid("7b928290-b6d2-469e-ac10-29eb36b8c1f6");
65 | $gateway->setTestMode(TRUE);
66 |
67 | $response = $gateway->purchase([
68 | 'amount' => 10.00
69 | ]
70 | )->send();
71 |
72 | if ($response->isSuccessful()) {
73 | echo $response->getTransactionReference();
74 | echo $response->getMessage();
75 | }else{
76 | echo $response->getError();
77 | }
78 |
79 | // Debug
80 | //var_dump($response);
81 |
82 | }
83 |
84 | }
85 |
86 | ## NestPay (EST)
87 | (İş Bankası, Akbank, Finansbank, Denizbank, Kuveytturk, Halkbank, Anadolubank, ING Bank, Citibank, Cardplus) gateway for Omnipay payment processing library
88 | https://github.com/yasinkuyu/omnipay-nestpay
89 |
90 | ## Iyzico
91 | Iyzico gateway for Omnipay payment processing library
92 | https://github.com/yasinkuyu/omnipay-iyzico
93 |
94 | ## GVP (Granti Sanal Pos)
95 | Gvp (Garanti, Denizbank, TEB, ING, Şekerbank, TFKB) gateway for Omnipay payment processing library
96 | https://github.com/yasinkuyu/omnipay-gvp
97 |
98 | ## Postnet
99 | Posnet (Yapı Kredi, Vakıfbank, Anadolubank) gateway for Omnipay payment processing library
100 | https://github.com/yasinkuyu/omnipay-posnet
101 |
102 | ## Paratika
103 | Paratika (Asseco) (Akbank, TEB, Halkbank, Finansbank, İş Bankası, Şekerbank, Vakıfbank ) gateway for Omnipay payment processing library
104 | https://github.com/yasinkuyu/omnipay-paratika
105 |
106 | ## Support
107 |
108 | If you are having general issues with Omnipay, we suggest posting on
109 | [Stack Overflow](http://stackoverflow.com/). Be sure to add the
110 | [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.
111 |
112 | If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
113 | you can subscribe to.
114 |
115 | If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/yasinkuyu/omnipay-bkm/issues),
116 | or better yet, fork the library and submit a pull request.
117 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yasinkuyu/omnipay-bkm",
3 | "type": "library",
4 | "description": "BKM Express gateway for Omnipay payment processing library",
5 | "keywords": [
6 | "posnet",
7 | "bkm",
8 | "sanal pos",
9 | "gateway",
10 | "merchant",
11 | "omnipay",
12 | "pay",
13 | "payment"
14 | ],
15 | "homepage": "https://github.com/yasinkuyu/omnipay-bkm",
16 | "license": "MIT",
17 | "authors": [
18 | {
19 | "name": "Yasin Kuyu",
20 | "email": "yasinkuyu@gmail.com"
21 | },
22 | {
23 | "name": "Omnipay Contributors",
24 | "homepage": "https://github.com/yasinkuyu/omnipay-bkm/contributors"
25 | }
26 | ],
27 | "autoload": {
28 | "psr-4": {
29 | "Omnipay\\Bkm\\": "src/"
30 | }
31 | },
32 | "require": {
33 | "omnipay/common": "~2.0"
34 | },
35 | "require-dev": {
36 | "omnipay/tests": "~2.0"
37 | },
38 | "extra": {
39 | "branch-alias": {
40 | "dev-master": "2.0.x-dev"
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ./src
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Gateway.php:
--------------------------------------------------------------------------------
1 | '',
23 | 'installment' => '',
24 | 'currency' => 'TRY',
25 | 'testMode' => false
26 | );
27 | }
28 |
29 | public function authorize(array $parameters = array()) {
30 | return $this->createRequest('\Omnipay\Bkm\Message\AuthorizeRequest', $parameters);
31 | }
32 |
33 | public function capture(array $parameters = array()) {
34 | return $this->createRequest('\Omnipay\Bkm\Message\CaptureRequest', $parameters);
35 | }
36 |
37 | public function purchase(array $parameters = array()) {
38 | return $this->createRequest('\Omnipay\Bkm\Message\PurchaseRequest', $parameters);
39 | }
40 |
41 | public function refund(array $parameters = array()) {
42 | return $this->createRequest('\Omnipay\Bkm\Message\RefundRequest', $parameters);
43 | }
44 |
45 | public function void(array $parameters = array()) {
46 | return $this->createRequest('\Omnipay\Bkm\Message\VoidRequest', $parameters);
47 | }
48 |
49 | public function getBank() {
50 | return $this->getParameter('bank');
51 | }
52 |
53 | public function setBank($value) {
54 | return $this->setParameter('bank', $value);
55 | }
56 |
57 | public function getMid() {
58 | return $this->getParameter('mid');
59 | }
60 |
61 | public function setMid($value) {
62 | return $this->setParameter('mid', $value);
63 | }
64 |
65 |
66 | public function getInstallment() {
67 | return $this->getParameter('installment');
68 | }
69 |
70 | public function setInstallment($value) {
71 | return $this->setParameter('installment', $value);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/Message/AuthorizeRequest.php:
--------------------------------------------------------------------------------
1 | 'https://preprod.bkmexpress.com.tr:9620/BKMExpress/BkmExpressPaymentService.ws',
19 | 'prod' => 'https://www.bkmexpress.com.tr:9620/BKMExpress/BkmExpressPaymentService.ws',
20 | ];
21 | protected $str;
22 |
23 | public function getData() {
24 |
25 | $timestamp = strftime("%Y%m%d-%H:%M:%S", time());
26 |
27 | $data = array(
28 | 'mId' => $this->getMid(),
29 | 'sUrl' => "http://local.instore/?success",
30 | 'cUrl' => "http://local.instore/?fail",
31 |
32 | 'sAmount' => $this->getAmountInteger(),
33 | 'cAmount' => "", //shipping price
34 | 'instOpst' => array(
35 | 'bank' => array(
36 | 'id' => 0046,
37 | 'name' => 'AKBANK',
38 | 'expBank' => 'AKBANK',
39 | 'bins' => array(
40 | 'bins' => array(
41 | 'value' => '557113',
42 | 'insts' => array(
43 | 'inst' => array(
44 | 'nofInst' => '1',
45 | 'amountInst' => '80,99',
46 | 'cAmount' => '5,00',
47 | 'cAmount' => '80,99',
48 | 'cPaid1stInst' => true,
49 | 'expInst' => 'test'
50 | ),
51 | 'inst' => array(
52 | 'nofInst' => '2',
53 | 'amountInst' => '42,99',
54 | 'cAmount' => '5,00',
55 | 'cAmount' => '84,99',
56 | 'cPaid1stInst' => false,
57 | 'expInst' => 'test'
58 | ),
59 | ),
60 | ),
61 | ),
62 | ),
63 | ),
64 | 'ts' => $timestamp,
65 | );
66 |
67 | $signData = function ($data) use (&$signData) {
68 |
69 | foreach ($data as $value) {
70 | if (is_array($value)) {
71 | $signData($value);
72 | } else {
73 | $this->str .= $value;
74 | }
75 | }
76 |
77 | };
78 | $signData($data);
79 |
80 | $data += array(
81 | 's' => $this->getSign(
82 | $this->str
83 | ),
84 | );
85 |
86 | return $data;
87 | }
88 |
89 | public function sendData($data) {
90 |
91 | $document = new DOMDocument('1.0', 'utf-8');
92 |
93 | $root = $document->createElement('bkm:initializePaymentWSRequest');
94 |
95 | // recursive array to xml
96 | $xml = function ($root, $data) use ($document, &$xml) {
97 | foreach ($data as $key => $value) {
98 | if (is_array($value)) {
99 | $subs = $document->createElement($key);
100 | $root->appendChild($subs);
101 | $xml($subs, $value);
102 | } else {
103 | $root->appendChild($document->createElement($key, $value));
104 | }
105 | }
106 | };
107 |
108 | $xml($root, $data);
109 |
110 | $bkm = $document->createElement('bkm:initializePayment');
111 | $bkm->appendChild($root);
112 |
113 | $envelope = $document->appendChild(
114 | $document->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'soapenv:Envelope')
115 | );
116 |
117 | $envelope->setAttribute('xmlns:bkm', 'http://www.bkmexpress.com.tr');
118 | $body = $envelope->appendChild($document->createElement('soapenv:Body'));
119 | $body->appendChild($bkm);
120 |
121 | $headers = array('Content-Type' => 'text/xml; charset=utf-8');
122 |
123 | $endpoint = $this->getTestMode() ? $this->endpoints["preprod"] : $this->endpoints["prod"];
124 |
125 | // Register the payment
126 | $this->httpClient->setConfig(array(
127 | 'curl.options' => array(
128 | 'CURLOPT_SSL_VERIFYHOST' => 2,
129 | 'CURLOPT_SSLVERSION' => 0,
130 | 'CURLOPT_SSL_VERIFYPEER' => 0,
131 | 'CURLOPT_RETURNTRANSFER' => 1,
132 | 'CURLOPT_SSL_CIPHER_LIST' => 'TLSv1'
133 | )
134 | ));
135 |
136 | $httpResponse = $this->httpClient->post($endpoint, $headers, $document->saveXML())->send();
137 |
138 | return $this->response = new Response($this, $httpResponse->getBody());
139 |
140 | }
141 |
142 | function getSign($data) {
143 | $priKey = file_get_contents(__DIR__ . '/bkm/bkm_client_sign_certificate_test.pem');
144 | $res = openssl_get_privatekey($priKey);
145 | openssl_sign($data, $sign, $res);
146 | openssl_free_key($res);
147 | $sign = base64_encode($sign);
148 | return $sign;
149 | }
150 |
151 | function getVerify($data, $sign) {
152 | $pubKey = file_get_contents(__DIR__ . '/bkm/bkm.pem');
153 | $res = openssl_get_publickey($pubKey);
154 | $result = (bool)openssl_verify($data, base64_decode($sign), $res);
155 | openssl_free_key($res);
156 | return $result;
157 | }
158 |
159 | public function getBank() {
160 | return $this->getParameter('bank');
161 | }
162 |
163 | public function setBank($value) {
164 | return $this->setParameter('bank', $value);
165 | }
166 |
167 | public function getMid() {
168 | return $this->getParameter('mid');
169 | }
170 |
171 | public function setMid($value) {
172 | return $this->setParameter('mid', $value);
173 | }
174 |
175 |
176 | public function getInstallment() {
177 | return $this->getParameter('installment');
178 | }
179 |
180 | public function setInstallment($value) {
181 | return $this->setParameter('installment', $value);
182 | }
183 |
184 | }
185 |
--------------------------------------------------------------------------------
/src/Message/RefundRequest.php:
--------------------------------------------------------------------------------
1 | request = $request;
28 | try {
29 |
30 | $this->data = new SimpleXMLElement($data);
31 |
32 | $this->data = $this->data->children("S", true)->Body->
33 | children("ns2", true)->initializePaymentResponse;
34 |
35 | } catch (\Exception $ex) {
36 | throw new InvalidResponseException();
37 | }
38 |
39 |
40 | }
41 |
42 | /**
43 | * Whether or not response is successful
44 | *
45 | * @return bool
46 | */
47 | public function isSuccessful() {
48 |
49 | if(isset($this->data->children()->InitializePaymentWSResponse))
50 | {
51 | $message = $this->data->
52 | children()->InitializePaymentWSResponse->
53 | children()->res->
54 | children()->resMsg;
55 |
56 | return (string) $message === "Success";
57 | }else{
58 | return false;
59 | }
60 |
61 | }
62 |
63 | /**
64 | * Get is redirect
65 | *
66 | * @return bool
67 | */
68 | public function isRedirect() {
69 | return false; //todo
70 | }
71 |
72 | /**
73 | * Get a code describing the status of this response.
74 | *
75 | * @return string|null code
76 | */
77 | public function getCode() {
78 |
79 | if(isset($this->data->children()->InitializePaymentWSResponse))
80 | {
81 | $code = $this->data->
82 | children()->InitializePaymentWSResponse->
83 | children()->res->
84 | children()->resCode;
85 |
86 | return $code;
87 | }
88 |
89 | }
90 |
91 | /**
92 | * Get transaction reference
93 | *
94 | * @return string
95 | */
96 | public function getTransactionReference() {
97 |
98 | if(isset($this->data->children()->InitializePaymentWSResponse))
99 | {
100 | $transId = $this->data->
101 | children()->InitializePaymentWSResponse->
102 | children()->t;
103 |
104 | return $transId;
105 | }
106 |
107 | }
108 |
109 | /**
110 | * Get message
111 | *
112 | * @return string
113 | */
114 | public function getMessage() {
115 | if ($this->isSuccessful()) {
116 | $message = $this->data->
117 | children("ns2", true)->initializePaymentWSResponse->
118 | children()->result->resultMsg;
119 |
120 | return $message;
121 | }
122 | return $this->getError();
123 | }
124 |
125 | /**
126 | * Get error
127 | *
128 | * @return string
129 | */
130 | public function getError() {
131 |
132 | $message = $this->data->
133 | children("ns2", true)->initializePaymentWSResponse->
134 | children()->result->resultMsg;
135 |
136 | return $message;
137 | }
138 |
139 | /**
140 | * Get Redirect url
141 | *
142 | * @return string
143 | */
144 | public function getRedirectUrl() {
145 | if ($this->isRedirect()) {
146 | $data = array(
147 | 'TransId' => $this->getTransactionReference()
148 | );
149 | return $this->getRequest()->getEndpoint() . '/test/index?' . http_build_query($data);
150 | }
151 | }
152 |
153 | /**
154 | * Get Redirect method
155 | *
156 | * @return POST
157 | */
158 | public function getRedirectMethod() {
159 | return 'POST';
160 | }
161 |
162 | /**
163 | * Get Redirect url
164 | *
165 | * @return null
166 | */
167 | public function getRedirectData() {
168 | return null;
169 | }
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/src/Message/VoidRequest.php:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/Message/bkm/BkmExpressPaymentService.xsd:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
--------------------------------------------------------------------------------
/src/Message/bkm/RequestMerchInfoService_clear.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/src/Message/bkm/RequestMerchInfoService_latest.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/Message/bkm/RequestMerchInfoService_latest.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/src/Message/bkm/bkm.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7b1qxP83swSQ4WB6QMC
3 | 4SvPFFcLSdyiv0CVe3mxBjDeIMsYsh1zk6xU+6nSNvCSNcSvTY6SJ7FjuOFINaj6
4 | BLW40K1NOEyvVv4mnd5AhyEpyQiX0b3FacqPGKdyG3w3SxDc6YkhJVuL4h1CNgvY
5 | yKH+OOTi4y4izs5qVqeyL8yCttXDM6WbR8kzBVNzH4EihOyKOEcZLsdrvGoIbo1T
6 | R7jc41JnLmBr3Krm6ZpAFUDcNw7X0GqjOBjpDt5KmvdMTr0w0d1PD54dV8kvS8gK
7 | niHhtRCqfea20/VBSY1k0ZqQG8LLayxMXfYgXjsOD7nWq4663XSAnKjsI8NK7Cas
8 | ZQIDAMjD
9 | -----END PUBLIC KEY-----
10 |
--------------------------------------------------------------------------------
/src/Message/bkm/bkm.pub:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDWjCCAkICAQEwDQYJKoZIhvcNAQEFBQAwczEMMAoGA1UEAxMDQktNMSMwIQYD
3 | VQQKExpCYW5rYWxhcmFyYXNpIEthcnQgTWVya2V6aTERMA8GA1UECxMIM0RTZWN1
4 | cmUxETAPBgNVBAcTCElzdGFuYnVsMQswCQYDVQQIEwJUUjELMAkGA1UEBhMCVFIw
5 | HhcNMTIwNjEzMDkxNjU4WhcNMTMwNjEzMDkxNjU4WjBzMQwwCgYDVQQDEwNCS00x
6 | IzAhBgNVBAoTGkJhbmthbGFyYXJhc2kgS2FydCBNZXJrZXppMREwDwYDVQQLEwgz
7 | RFNlY3VyZTERMA8GA1UEBxMISXN0YW5idWwxCzAJBgNVBAgTAlRSMQswCQYDVQQG
8 | EwJUUjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALO29asT/N7MEkOF
9 | gekDAuErzxRXC0ncor9AlXt5sQYw3iDLGLIdc5OsVPup0jbwkjXEr02OkiexY7jh
10 | SDWo+gS1uNCtTThMr1b+Jp3eQIchKckIl9G9xWnKjxincht8N0sQ3OmJISVbi+Id
11 | QjYL2Mih/jjk4uMuIs7Oalansi/MgrbVwzOlm0fJMwVTcx+BIoTsijhHGS7Ha7xq
12 | CG6NU0e43ONSZy5ga9yq5umaQBVA3DcO19BqozgY6Q7eSpr3TE69MNHdTw+eHVfJ
13 | L0vICp4h4bUQqn3mttP1QUmNZNGakBvCy2ssTF32IF47Dg+51quOut10gJyo7CPD
14 | SuwmrGUCAwDIwzANBgkqhkiG9w0BAQUFAAOCAQEASaW8nrvXKNOJock9bGz+R8wI
15 | W+nPTgy0f2/9c6Pxpidbs9aasLuT4wUdIbqOLyTYWdwdKkTm+vSBCd0ZnnCVDtEA
16 | EaEE9iI1gMOZiKUf16szuKXtBXrfPbksyyYpOYIH/PDipQwsyKo6BQZNDW918Cwq
17 | JduiVGEnJPc/W8x1GAr2FTbXlVHD41+6es06saV38PzYgpg9xtQprkGRaj3fX9OV
18 | hcZmotzKL1+Eifk5rTH+QrhjCMXD+wOmc2dMi9U2FVQW0FNM4steMPEY3Vs+A7xV
19 | T3VV5b/t07rrdOjZhSDW6/zL39hoibEsG9QvcUD9gXamqqSmFxsmzxAJZhAmEg==
20 | -----END CERTIFICATE-----
--------------------------------------------------------------------------------
/src/Message/bkm/bkm_client_sign_certificate_test.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIICXAIBAAKBgQCmT98a0rIgdjY7dHtBVDlyuP/f0OS2fdoIfz7eE/PS96DCu6UV
3 | y85OPs//O7Z0rCbL1P5VkDayLduaQ5jSFq52Dy4TYpv4BuIxURFMXKWbG7nSab7z
4 | f4qzyjdlSjp5jAiUxxzdf4tA52omMv9WKvvhe268PN8yHNfRkzK7tH6K6QIDAQAB
5 | AoGBAJtIgjCiP2zt0u8qcBbsVANY1pgcjCAUW+qJHKLwED2Ptkt8NsSmGYeXQE+4
6 | akB/qG2y/pHXaCpvhNaBfQPT56mUQa0HwuavSEfftG3OVsrFhA1/9x/07v5bba53
7 | X9zKbFU44EYPEQBj0tKdk+3AfKV1T01GhQWBNy3VhZkNm8eBAkEA1G4ruPPj+q20
8 | FIC8eceNxKkdbfZe15nXesIplGLA4tp8hnU5hS1iRZKekxgKdAfofLFRTIEJHPJ6
9 | LgvHpL19+QJBAMhsN/+9MgOiCFI2sy0PuUozjFCA4L9bV0YMfyiPdPoevPcN84c0
10 | MMUc9qkTbny4MoDZ/27jPbYy0VLn1BblcHECQAzlv3vUOvQ+VZ+lDUxrhDz7c5D4
11 | k1uNuJp4bWPX9xQO5d6YAW0Hi17j/wK5Q/E1hbUEYwY9E1uRkT94cZ+b7akCQAmf
12 | wLSkFiG8hx/DhqkURzZ78THwblph/Xfco8KD2P8luLc4UUhdxjXA5UtLJpQQmEQ9
13 | s5lUiiMUn56WiUWsMNECQDZk9XVd7tzLCDfqJaMfhNqe8DGbacJXEpARRMPPZpA2
14 | RSTnnydi/g5Tcv/ryd4DM6FmHO2uh3mv6ekDNY1FRyM=
15 | -----END RSA PRIVATE KEY-----
16 |
--------------------------------------------------------------------------------
/src/Message/bkm/bkm_client_sign_certificate_test.pub:
--------------------------------------------------------------------------------
1 | -----BEGIN PUBLIC KEY-----
2 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmT98a0rIgdjY7dHtBVDlyuP/f
3 | 0OS2fdoIfz7eE/PS96DCu6UVy85OPs//O7Z0rCbL1P5VkDayLduaQ5jSFq52Dy4T
4 | Ypv4BuIxURFMXKWbG7nSab7zf4qzyjdlSjp5jAiUxxzdf4tA52omMv9WKvvhe268
5 | PN8yHNfRkzK7tH6K6QIDAQAB
6 | -----END PUBLIC KEY-----
7 |
--------------------------------------------------------------------------------
/tests/GatewayTest.php:
--------------------------------------------------------------------------------
1 | gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
20 |
21 | $this->options = array(
22 | 'apiId' => '6700000067',
23 | 'secretKey' => '67000067',
24 | 'mode' => 'test',
25 | 'amount' => 100,
26 | 'currency' => 'TRY',
27 | 'card' => new CreditCard(array(
28 | 'number' => '4506341010205499',
29 | 'expiryMonth' => '03',
30 | 'expiryYear' => '2017',
31 | 'cvv' => '000'
32 | )),
33 | );
34 | }
35 |
36 | public function testPurchase()
37 | {
38 | $this->setMockHttpResponse('PurchaseSuccess.txt');
39 |
40 | $response = $this->gateway->purchase($this->options)->send();
41 |
42 | $this->assertInstanceOf('\Omnipay\Bkm\Message\Response', $response);
43 | $this->assertTrue($response->isSuccessful());
44 | $this->assertEquals('130215141054377801316798', $response->getTransactionReference());
45 | }
46 |
47 | public function testPurchaseError()
48 | {
49 | $this->setMockHttpResponse('PurchaseFailure.txt');
50 |
51 | $response = $this->gateway->purchase($this->options)->send();
52 |
53 | $this->assertFalse($response->isSuccessful());
54 | $this->assertSame('Input variable errors', $response->getMessage());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/tests/Message/RefundRequestTest.php:
--------------------------------------------------------------------------------
1 | request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest());
19 | $this->request->initialize(
20 | array(
21 | 'amount' => '11.00',
22 | 'currency' => 'TRY',
23 | 'testMode' => true,
24 | )
25 | );
26 | }
27 |
28 | public function testGetData()
29 | {
30 | $data = $this->request->getData();
31 |
32 | /*
33 | * See https://bugs.php.net/bug.php?id=29500 for why this is cast to string
34 | */
35 | $this->assertSame('CC.DB', (string)$data['Type']);
36 | $this->assertSame('1200', (string)$data['Amount']);
37 | $this->assertSame('TRY', (string)$data['Currency']);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/tests/Message/ResponseTest.php:
--------------------------------------------------------------------------------
1 | getMockHttpResponse('PurchaseFailureWithoutStatusCode.txt');
21 | new Response($this->getMockRequest(), $httpResponse->getBody());
22 | }
23 |
24 | public function testPurchaseSuccess()
25 | {
26 | $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt');
27 | $response = new Response($this->getMockRequest(), $httpResponse->getBody());
28 |
29 | $this->assertTrue($response->isSuccessful());
30 | $this->assertEquals('130215141054377801316798', $response->getTransactionReference());
31 | $this->assertSame('AuthCode: 672167', $response->getMessage());
32 | $this->assertEmpty($response->getRedirectUrl());
33 | }
34 |
35 | public function testPurchaseFailure()
36 | {
37 | $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt');
38 | $response = new Response($this->getMockRequest(), $httpResponse->getBody());
39 |
40 | $this->assertFalse($response->isSuccessful());
41 | $this->assertSame('', $response->getTransactionReference());
42 | $this->assertSame('Input variable errors', $response->getMessage());
43 | }
44 |
45 | public function testRedirect()
46 | {
47 | $httpResponse = $this->getMockHttpResponse('PurchaseRedirect.txt');
48 |
49 | $request = m::mock('\Omnipay\Common\Message\AbstractRequest');
50 | $request->shouldReceive('getReturnUrl')->once()->andReturn('http://sanalmagaza.org/');
51 |
52 | $response = new Response($request, $httpResponse->getBody());
53 |
54 | $this->assertTrue($response->isRedirect());
55 | $this->assertSame('POST', $response->getRedirectMethod());
56 | $this->assertSame('http://sanalmagaza.org/', $response->getRedirectUrl());
57 |
58 | $expectedData = array(
59 | 'ReturnUrl' => 'http://sanalmagaza.org/',
60 | 'ReferanceId' => '130215141054377801316798'
61 | );
62 | $this->assertEquals($expectedData, $response->getRedirectData());
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tests/Mock/PurchaseFailure.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yasinkuyu/omnipay-bkm/9057c1af91e16a96f9089484389a1e322332f7ba/tests/Mock/PurchaseFailure.txt
--------------------------------------------------------------------------------
/tests/Mock/PurchaseFailureWithoutStatusCode.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yasinkuyu/omnipay-bkm/9057c1af91e16a96f9089484389a1e322332f7ba/tests/Mock/PurchaseFailureWithoutStatusCode.txt
--------------------------------------------------------------------------------
/tests/Mock/PurchaseRedirect.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yasinkuyu/omnipay-bkm/9057c1af91e16a96f9089484389a1e322332f7ba/tests/Mock/PurchaseRedirect.txt
--------------------------------------------------------------------------------
/tests/Mock/PurchaseSuccess.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yasinkuyu/omnipay-bkm/9057c1af91e16a96f9089484389a1e322332f7ba/tests/Mock/PurchaseSuccess.txt
--------------------------------------------------------------------------------