Skip to content

Commit 639c3e9

Browse files
committed
Added Portmanat Card Gateway
1 parent a6dfbe0 commit 639c3e9

24 files changed

+990
-111
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ php:
66
- 5.5
77
- 5.6
88
- 7.0
9+
- 7.1
910
- hhvm
1011

1112
before_script:

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
**Portmanat driver for the Omnipay PHP payment processing library**
44

5-
[![Build Status](https://travis-ci.org/dercoder/omnipay-portmanat.png?branch=master)](https://travis-ci.org/dercoder/omnipay-portmanat)
5+
[![Build Status](https://travis-ci.org/dercoder/omnipay-portmanat.svg?branch=master)](https://travis-ci.org/dercoder/omnipay-portmanat)
66
[![Coverage Status](https://coveralls.io/repos/dercoder/omnipay-portmanat/badge.svg?branch=master&service=github)](https://coveralls.io/github/dercoder/omnipay-portmanat?branch=master)
7-
[![Dependency Status](https://www.versioneye.com/user/projects/560a99a45a262f001e000661/badge.png)](https://www.versioneye.com/user/projects/560a99a45a262f001e000661)
87

98
[![Latest Stable Version](https://poser.pugx.org/dercoder/omnipay-portmanat/v/stable.png)](https://packagist.org/packages/dercoder/omnipay-portmanat)
109
[![Total Downloads](https://poser.pugx.org/dercoder/omnipay-portmanat/downloads.png)](https://packagist.org/packages/dercoder/omnipay-portmanat)
1110
[![Latest Unstable Version](https://poser.pugx.org/dercoder/omnipay-portmanat/v/unstable.png)](https://packagist.org/packages/dercoder/omnipay-portmanat)
1211
[![License](https://poser.pugx.org/dercoder/omnipay-portmanat/license.png)](https://packagist.org/packages/dercoder/omnipay-portmanat)
1312

1413
[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
15-
processing library for PHP 5.3+. This package implements [Portmanat](https://www.portmanat.az) support for Omnipay.
14+
processing library for PHP 5.3+.
15+
This package implements [Portmanat](https://www.portmanat.az)
16+
and [Portmanat Card](https://www.mps.az)
17+
support for Omnipay.
1618

1719
## Installation
1820

@@ -37,6 +39,7 @@ And run composer to update your dependencies:
3739
The following gateways are provided by this package:
3840

3941
* Portmanat
42+
* Portmanat Card
4043

4144
For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)
4245
repository.

composer.json

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
{
2-
"name": "dercoder/omnipay-portmanat",
3-
"type": "library",
4-
"description": "Portmanat driver for the Omnipay payment processing library",
5-
"keywords": [
6-
"portmanat",
7-
"gateway",
8-
"merchant",
9-
"omnipay",
10-
"pay",
11-
"payment"
12-
],
13-
"homepage": "https://github.com/dercoder/omnipay-portmanat",
14-
"license": "MIT",
15-
"authors": [
16-
{
17-
"name": "Alexander Fedra",
18-
"email": "alexander.fedra@gmail.com"
19-
}
20-
],
21-
"autoload": {
22-
"psr-4": {
23-
"Omnipay\\Portmanat\\": "src/"
24-
}
25-
},
26-
"require": {
27-
"omnipay/common": "~2.3"
28-
},
29-
"require-dev": {
30-
"omnipay/tests": "~2.0",
31-
"satooshi/php-coveralls": "1.0.0"
32-
},
33-
"extra": {
34-
"branch-alias": {
35-
"dev-master": "1.0.x-dev"
36-
}
2+
"name": "dercoder/omnipay-portmanat",
3+
"type": "library",
4+
"description": "Portmanat driver for the Omnipay payment processing library",
5+
"keywords": [
6+
"portmanat",
7+
"mps",
8+
"gateway",
9+
"merchant",
10+
"omnipay",
11+
"pay",
12+
"payment"
13+
],
14+
"homepage": "https://github.com/dercoder/omnipay-portmanat",
15+
"license": "MIT",
16+
"authors": [
17+
{
18+
"name": "Alexander Fedra",
19+
"email": "alexander.fedra@gmail.com"
3720
}
21+
],
22+
"autoload": {
23+
"psr-4": {
24+
"Omnipay\\Portmanat\\": "src/"
25+
}
26+
},
27+
"require": {
28+
"omnipay/common": "~2.5"
29+
},
30+
"require-dev": {
31+
"omnipay/tests": "~2.0",
32+
"satooshi/php-coveralls": "1.0.0"
33+
},
34+
"extra": {
35+
"branch-alias": {
36+
"dev-master": "1.0.x-dev"
37+
}
38+
}
3839
}

src/CardGateway.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace Omnipay\Portmanat;
4+
5+
use Omnipay\Common\AbstractGateway;
6+
use Omnipay\Common\Message\AbstractCardRequest;
7+
use Omnipay\Portmanat\Message\CardCompletePurchaseRequest;
8+
use Omnipay\Portmanat\Message\CardFetchTransactionRequest;
9+
use Omnipay\Portmanat\Message\CardPurchaseRequest;
10+
11+
/**
12+
* Class CardGateway
13+
* @package Omnipay\Portmanat
14+
*/
15+
class CardGateway extends AbstractGateway
16+
{
17+
/**
18+
* @return string
19+
*/
20+
public function getName()
21+
{
22+
return 'Portmanat Card';
23+
}
24+
25+
/**
26+
* @return array
27+
*/
28+
public function getDefaultParameters()
29+
{
30+
return array(
31+
'serviceId' => '',
32+
'secretKey' => '',
33+
'testMode' => false
34+
);
35+
}
36+
37+
/**
38+
* Get MPS service ID.
39+
*
40+
* @return string serviceId
41+
*/
42+
public function getServiceId()
43+
{
44+
return $this->getParameter('serviceId');
45+
}
46+
47+
/**
48+
* Set MPS service ID.
49+
*
50+
* @param string $value serviceId
51+
*
52+
* @return $this
53+
*/
54+
public function setServiceId($value)
55+
{
56+
return $this->setParameter('serviceId', $value);
57+
}
58+
59+
/**
60+
* Get MPS secret key.
61+
*
62+
* @return string secretKey
63+
*/
64+
public function getSecretKey()
65+
{
66+
return $this->getParameter('secretKey');
67+
}
68+
69+
/**
70+
* Set MPS secret key.
71+
*
72+
* @param string $value
73+
*
74+
* @return $this
75+
*/
76+
public function setSecretKey($value)
77+
{
78+
return $this->setParameter('secretKey', $value);
79+
}
80+
81+
/**
82+
* @param array $parameters
83+
*
84+
* @return AbstractCardRequest|CardPurchaseRequest
85+
*/
86+
public function purchase(array $parameters = array())
87+
{
88+
return $this->createRequest('\Omnipay\Portmanat\Message\CardPurchaseRequest', $parameters);
89+
}
90+
91+
/**
92+
* @param array $parameters
93+
*
94+
* @return AbstractCardRequest|CardCompletePurchaseRequest
95+
*/
96+
public function completePurchase(array $parameters = array())
97+
{
98+
return $this->createRequest('\Omnipay\Portmanat\Message\CardCompletePurchaseRequest', $parameters);
99+
}
100+
101+
/**
102+
* @param array $parameters
103+
*
104+
* @return AbstractCardRequest|CardFetchTransactionRequest
105+
*/
106+
public function fetchTransaction(array $parameters = array())
107+
{
108+
return $this->createRequest('\Omnipay\Portmanat\Message\CardFetchTransactionRequest', $parameters);
109+
}
110+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Omnipay\Portmanat\Message;
4+
5+
/**
6+
* Class CardAbstractRequest
7+
* @package Omnipay\Portmanat\Message
8+
*/
9+
abstract class AbstractCardRequest extends \Omnipay\Common\Message\AbstractRequest
10+
{
11+
/**
12+
* @var string
13+
*/
14+
protected $endpoint = 'http://psp.mps.az/check';
15+
16+
/**
17+
* Get API endpoint URL
18+
*
19+
* @return string
20+
*/
21+
public function getEndpoint()
22+
{
23+
return $this->endpoint;
24+
}
25+
26+
/**
27+
* Get Portmanat service ID.
28+
*
29+
* @return string serviceId
30+
*/
31+
public function getServiceId()
32+
{
33+
return $this->getParameter('serviceId');
34+
}
35+
36+
/**
37+
* Set Portmanat service ID.
38+
*
39+
* @param string $value serviceId
40+
*
41+
* @return $this
42+
*/
43+
public function setServiceId($value)
44+
{
45+
return $this->setParameter('serviceId', $value);
46+
}
47+
48+
/**
49+
* Get Portmanat secret key.
50+
*
51+
* @return string secretKey
52+
*/
53+
public function getSecretKey()
54+
{
55+
return $this->getParameter('secretKey');
56+
}
57+
58+
/**
59+
* Set Portmanat secret key.
60+
*
61+
* @param string $value
62+
*
63+
* @return $this
64+
*/
65+
public function setSecretKey($value)
66+
{
67+
return $this->setParameter('secretKey', $value);
68+
}
69+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Omnipay\Portmanat\Message;
4+
5+
use Omnipay\Common\Exception\InvalidRequestException;
6+
7+
/**
8+
* Class CardCompletePurchaseRequest
9+
* @package Omnipay\Portmanat\Message
10+
*/
11+
class CardCompletePurchaseRequest extends AbstractCardRequest
12+
{
13+
/**
14+
* @return array
15+
* @throws InvalidRequestException
16+
*/
17+
public function getData()
18+
{
19+
if (!$transactionReference = $this->httpRequest->get('psp_rrn')) {
20+
throw new InvalidRequestException('The psp_rrn parameter is required');
21+
}
22+
23+
$data = array(
24+
'psp_rrn' => $transactionReference
25+
);
26+
27+
return $data;
28+
}
29+
30+
/**
31+
* @param array $data
32+
*
33+
* @return CardCompletePurchaseResponse
34+
*/
35+
public function sendData($data)
36+
{
37+
$headers = array(
38+
'Content-Type' => 'application/json; charset=utf-8'
39+
);
40+
41+
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
42+
$httpResponse = $httpRequest->send();
43+
$jsonResponse = $httpResponse->json();
44+
45+
return new CardCompletePurchaseResponse($this, $jsonResponse);
46+
}
47+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Omnipay\Portmanat\Message;
4+
5+
/**
6+
* Class CardCompletePurchaseResponse
7+
* @package Omnipay\Portmanat\Message
8+
*/
9+
class CardCompletePurchaseResponse extends CardFetchTransactionResponse
10+
{
11+
12+
}

0 commit comments

Comments
 (0)