-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoneris.php
80 lines (70 loc) · 2.19 KB
/
Moneris.php
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
<?php
namespace Zone\PaymentGateway\Integration;
use Zone\PaymentGateway\Exception;
use Zone\PaymentGateway\Helper;
use Zone\PaymentGateway\PaymentGateway;
use Zone\PaymentGateway\Response;
class Moneris extends PaymentGateway
{
/**
* @param $storeId
* @param $apiToken
*
* @return $this
*/
public function setCredentials($storeId, $apiToken)
{
$this->setApi(new API\Moneris($storeId, $apiToken, $this->getTestMode()));
return $this;
}
/**
* @param Response\CreateCharge $response
*/
public function createChargeResponse(Response\CreateCharge $response)
{
$this->setSuccess($response);
$response->setReferenceNumber($response->getApiResponse('ReferenceNum'));
$response->getTransaction()->setApiResponse($response->getApiResponse());
var_export($response);
}
/**
* @param Response\ReturnTransaction $response
*/
public function returnTransactionResponse(Response\ReturnTransaction $response)
{
$this->setSuccess($response);
if ($response->getSuccess()) {
$response->setReferenceNumber($response->getApiResponse('ReferenceNum'));
$response->getTransaction()->setApiResponse($response->getApiResponse());
}
}
/**
* @param Response\TransactionInfo $response
*
* @throws Exception\MethodNotSupportedException
*/
public function transactionInfoResponse(Response\TransactionInfo $response)
{
throw new Exception\MethodNotSupportedException('Transaction Info not supported');
}
/**
* @param Response\ValidateCard $response
*/
public function validateCardResponse(Response\ValidateCard $response)
{
$this->setSuccess($response);
}
/**
* @param Response\VoidTransaction $response
*/
public function voidTransactionResponse(Response\VoidTransaction $response)
{
$this->setSuccess($response);
}
/**
* @param Response\Response $response
*/
private function setSuccess($response) {
$response->setSuccess($response->getApiResponse('Complete') === 'true' && (int)$response->getApiResponse('ResponseCode') < 50);
}
}