-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathConnectGateway.php
175 lines (165 loc) · 5.17 KB
/
ConnectGateway.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
133
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* First Data Connect Gateway
*/
namespace Omnipay\FirstData;
use Omnipay\Common\AbstractGateway;
/**
* First Data Connect Gateway
*
* The First Data Global Gateway Connect 2.0 is a simple payment solution for connecting an
* online store to the First Data Global Gateway. It is referred to here as the "First Data
* Connect" gateway, currently at version 2.0.
*
* First Data Connect supports both a redirect method of payment and a direct post
* method of payment. So far only the direct post method of payment is supported by
* this gateway code.
*
* ### Form Hosting
*
* First Data Global Gateway Connect 2.0 allows two ways for collecting payment:
*
* * A redirect mode which uses the ready-made form pages for the payment process that
* First Data provides. With this option, you forward your customers to First Data
* for payment. They enter the cardholder data on First Data’s payment page.
* Afterwards, Connect 2.0 redirects the customer back to your website and notifies
* your website of the payment result.
*
* * You can create your own payment forms and host them on your server. Although your
* server hosts the forms, your website sends the cardholder data directly from the
* customer to the First Data Global Gateway
*
* ### Payment Modes
*
* First Data Global Gateway Connect 2.0 supports three different payment modes.
*
* * In PayOnly mode, First Data Global Gateway Connect 2.0 collects the minimum
* information needed to process a transaction.
*
* * In PayPlus mode, First Data Global Gateway Connect 2.0 collects the same payment
* information as in PayOnly mode plus a full set of billing information.
*
* * In FullPay mode, First Data Global Gateway Connect 2.0 collects the same payment
* and billing information collected in PayPlus mode plus shipping information.
*
* ### Test Accounts
*
* You can apply for a test account at this URL:
*
* http://www.firstdata.com/product_solutions/ecommerce/global_gateway/index.htm
*
* There are some issues with obtaining shared secrets for testing Connect 2.0.
*
* ### Example
*
* <code>
* // Create a gateway for the First Data Connect Gateway
* // (routes to GatewayFactory::create)
* $gateway = Omnipay::create('FirstData_Connect');
*
* // Initialise the gateway
* $gateway->initialize(array(
* 'storeId' => '12341234',
* 'sharedSecret' => 'IcantTELLyouITSaSECRET',
* 'testMode' => true, // Or false when you are ready for live transactions
* ));
*
* // Do a purchase transaction on the gateway
* $transaction = $gateway->purchase(array(
* 'description' => 'Your order for widgets',
* 'amount' => '10.00',
* 'transactionId' => 12345,
* ));
* $response = $transaction->send();
* if ($response->isSuccessful()) {
* echo "Purchase transaction was successful!\n";
* $sale_id = $response->getTransactionReference();
* echo "Transaction reference = " . $sale_id . "\n";
* }
* </code>
*
* @link https://www.firstdata.com/downloads/pdf/FDGG_Connect_2.0_Integration_Manual_v2.0.pdf
*/
class ConnectGateway extends AbstractGateway
{
public function getName()
{
return 'First Data Connect';
}
public function getDefaultParameters()
{
return array(
'storeId' => '',
'sharedSecret' => '',
'testMode' => false,
);
}
/**
* Set Store ID
*
* Calls to the Connect Gateway API are secured with a store ID and
* shared secret.
*
* @return ConnectGateway provides a fluent interface
*/
public function setStoreId($value)
{
return $this->setParameter('storeId', $value);
}
/**
* Get Store ID
*
* Calls to the Connect Gateway API are secured with a store ID and
* shared secret.
*
* @return string
*/
public function getStoreId()
{
return $this->getParameter('storeId');
}
/**
* Set Shared Secret
*
* Calls to the Connect Gateway API are secured with a store ID and
* shared secret.
*
* @return ConnectGateway provides a fluent interface
*/
public function setSharedSecret($value)
{
return $this->setParameter('sharedSecret', $value);
}
/**
* Get Shared Secret
*
* Calls to the Connect Gateway API are secured with a store ID and
* shared secret.
*
* @return string
*/
public function getSharedSecret()
{
return $this->getParameter('sharedSecret');
}
/**
* Create a purchase request.
*
* @param array $parameters
* @return \Omnipay\FirstData\Message\PurchaseRequest
*/
public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\FirstData\Message\PurchaseRequest', $parameters);
}
/**
* Create a complete purchase request.
*
* @param array $parameters
* @return \Omnipay\FirstData\Message\CompletePurchaseRequest
*/
public function completePurchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\FirstData\Message\CompletePurchaseRequest', $parameters);
}
}