Skip to content

Commit cf62ef2

Browse files
committed
Update files
1 parent 01bbdd8 commit cf62ef2

File tree

3 files changed

+90
-93
lines changed

3 files changed

+90
-93
lines changed

src/Gateway.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,33 @@ public function getName()
2121
public function getDefaultParameters()
2222
{
2323
return array(
24-
'name' => '',
24+
25+
'bank' => '',
26+
'username' => '',
2527
'clientId' => '',
26-
'password' => '',
28+
'password' => ''
29+
2730
);
2831
}
2932

33+
public function getBank()
34+
{
35+
return $this->getParameter('bank');
36+
}
37+
38+
public function setBank($value)
39+
{
40+
return $this->setParameter('bank', $value);
41+
}
42+
3043
public function getUserName()
3144
{
32-
return $this->getParameter('name');
45+
return $this->getParameter('username');
3346
}
3447

3548
public function setUserName($value)
3649
{
37-
return $this->setParameter('name', $value);
50+
return $this->setParameter('username', $value);
3851
}
3952

4053
public function getClientId()
@@ -56,16 +69,6 @@ public function setPassword($value)
5669
{
5770
return $this->setParameter('password', $value);
5871
}
59-
60-
public function getBank()
61-
{
62-
return $this->getParameter('bank');
63-
}
64-
65-
public function setBank($value)
66-
{
67-
return $this->setParameter('bank', $value);
68-
}
6972

7073
public function purchase(array $parameters = array())
7174
{

src/Message/AbstractRequest.php

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php namespace Omnipay\NestPay\Message;
22

3+
use Omnipay\Common\AbstractGateway;
4+
35
/**
46
* NestPay Purchase AbstractRequest
57
*
@@ -9,44 +11,5 @@
911
*/
1012
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
1113
{
12-
13-
public function getUserName()
14-
{
15-
return $this->getParameter('name');
16-
}
17-
18-
public function setUserName($value)
19-
{
20-
return $this->setParameter('name', $value);
21-
}
22-
23-
public function getClientId()
24-
{
25-
return $this->getParameter('clientId');
26-
}
27-
28-
public function setClientId($value)
29-
{
30-
return $this->setParameter('clientId', $value);
31-
}
32-
33-
public function getPassword()
34-
{
35-
return $this->getParameter('password');
36-
}
37-
38-
public function setPassword($value)
39-
{
40-
return $this->setParameter('password', $value);
41-
}
42-
43-
public function getBank()
44-
{
45-
return $this->getParameter('bank');
46-
}
47-
48-
public function setBank($value)
49-
{
50-
return $this->setParameter('bank', $value);
51-
}
14+
5215
}

src/Message/PurchaseRequest.php

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Omnipay\NestPay\Message;
1+
<?php
2+
3+
namespace Omnipay\NestPay\Message;
24

35
use DOMDocument;
46
use Omnipay\Common\Message\AbstractRequest;
@@ -10,34 +12,64 @@
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

Comments
 (0)