1- <?php namespace Omnipay \NestPay \Message ;
1+ <?php
2+
3+ namespace Omnipay \NestPay \Message ;
24
35use DOMDocument ;
46use Omnipay \Common \Message \AbstractRequest ;
1012 * 2015, insya.com
1113 * http://www.github.com/yasinkuyu/omnipay-nestpay
1214 */
13- class PurchaseRequest extends AbstractRequest
14- {
15-
16- protected $ endpoint = 'http://testsanalpos.est.com.tr/servlet/cc5ApiServer ' ;
15+ class PurchaseRequest extends AbstractRequest {
1716
17+ protected $ endpoint = 'https://testsanalpos.est.com.tr/servlet/cc5ApiServer ' ;
18+
19+ protected $ mode = 'TEST ' ;
20+
1821 protected $ endpoints = [
19- 'test ' => 'testsanalpos.est.com.tr ' ,
20- 'isbank ' => 'spos.isbank.com.tr ' ,
21- 'akbank ' => 'www.sanalakpos.com ' ,
22- 'finansbank ' => 'www.fbwebpos.com ' ,
23- 'halkbank ' => 'sanalpos.halkbank.com.tr ' ,
24- 'anadolubank ' => 'anadolusanalpos.est.com.tr '
22+ 'test ' => 'testsanalpos.est.com.tr ' ,
23+ 'isbank ' => 'spos.isbank.com.tr ' ,
24+ 'akbank ' => 'www.sanalakpos.com ' ,
25+ 'finansbank ' => 'www.fbwebpos.com ' ,
26+ 'halkbank ' => 'sanalpos.halkbank.com.tr ' ,
27+ 'anadolubank ' => 'anadolusanalpos.est.com.tr '
2528 ];
26-
27- public function __construct ()
28- {
29+
30+ public function getBank () {
31+ return $ this ->getParameter ('bank ' );
32+ }
33+
34+ public function setBank ($ value ) {
35+ return $ this ->setParameter ('bank ' , $ value );
36+ }
37+
38+ public function getUserName () {
39+ return $ this ->getParameter ('username ' );
40+ }
41+
42+ public function setUserName ($ value ) {
43+ return $ this ->setParameter ('username ' , $ value );
44+ }
45+
46+ public function getClientId () {
47+ return $ this ->getParameter ('clientId ' );
48+ }
49+
50+ public function setClientId ($ value ) {
51+ return $ this ->setParameter ('clientId ' , $ value );
52+ }
53+
54+ public function getPassword () {
55+ return $ this ->getParameter ('password ' );
56+ }
57+
58+ public function setPassword ($ value ) {
59+ return $ this ->setParameter ('password ' , $ value );
60+ }
61+
62+ public function getData () {
2963 $ gateway = $ this ->getBank ();
30-
31- if (!array_key_exists ($ gateway , $ this ->endpoints )){
64+
65+ if (!array_key_exists ($ gateway , $ this ->endpoints )) {
3266 throw new \Exception ('Invalid Gateway ' );
33- }else {
67+ } else {
3468 $ this ->endpoint = $ this ->endpoints [$ gateway ];
3569 }
36- $ this ->endpoint = $ this ->mode == 'TEST ' ? 'http:// ' . $ this ->endpoints ["test " ] .'/servlet/cc5ApiServer ' : 'http:// ' .$ this ->endpoints [$ gateway ].'/servlet/cc5ApiServer ' ;
37- }
38-
39- public function getData ()
40- {
70+ $ this ->endpoint = $ this ->mode == 'TEST ' ? 'http:// ' . $ this ->endpoints ["test " ] . '/servlet/cc5ApiServer ' : 'http:// ' . $ this ->endpoints [$ gateway ] . '/servlet/cc5ApiServer ' ;
71+
72+
4173 $ this ->validate ('amount ' , 'card ' );
4274 $ this ->getCard ()->validate ();
4375
@@ -54,31 +86,29 @@ public function getData()
5486 $ data ['Currency ' ] = 949 ; //$this->getCurrencyNumeric();
5587 $ data ['Taksit ' ] = 0 ;
5688
57- $ data ['Total ' ] = $ this ->getAmountInteger ();
58- $ data ['Email ' ] = $ this ->getCard ()->getEmail ();
89+ $ data ['Total ' ] = 10.00 ; $ this ->getAmount ();
90+ $ data ['Email ' ] = $ this ->getCard ()->getEmail ();
5991 $ data ['Number ' ] = $ this ->getCard ()->getNumber ();
60- $ data ['Expires ' ] = $ this ->getCard ()->getExpiryDate ('m ' ). $ this ->getCard ()->getExpiryDate ('y ' );
92+ $ data ['Expires ' ] = $ this ->getCard ()->getExpiryDate ('m ' ) . $ this ->getCard ()->getExpiryDate ('y ' );
6193 $ data ["Cvv2Val " ] = $ this ->getCard ()->getCvv ();
62- $ data ["IPAddress " ] = " 127.0.0.1 " ; // $this->getClientIp();
63-
94+ $ data ["IPAddress " ] = $ this ->getClientIp ();
95+
6496 /*
65- $data["BillTo"] = '';
66- $data["ShipTo"] = '';
67- $data["Extra"] = '';
68- */
69-
97+ $data["BillTo"] = '';
98+ $data["ShipTo"] = '';
99+ $data["Extra"] = '';
100+ */
101+
70102 return $ data ;
71-
72103 }
73104
74- public function sendData ($ data )
75- {
105+ public function sendData ($ data ) {
76106 $ document = new DOMDocument ('1.0 ' , 'ISO-8859-9 ' );
77-
107+
78108 $ root = $ document ->createElement ('CC5Request ' );
79-
80- foreach ( $ data as $ id => $ value )
81- {
109+
110+ // each array element
111+ foreach ( $ data as $ id => $ value ) {
82112 $ root ->appendChild ($ document ->createElement ($ id , $ value ));
83113 }
84114 $ document ->appendChild ($ root );
@@ -90,4 +120,5 @@ public function sendData($data)
90120
91121 return $ this ->response = new Response ($ this , $ httpResponse ->getBody ());
92122 }
123+
93124}
0 commit comments