1 | <?php |
||
12 | class EcommercePayment_Stripe extends EcommercePayment |
||
|
|||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private static $api_key_public = ""; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private static $api_key_private = ""; |
||
24 | |||
25 | /** |
||
26 | * set the required privacy link as you see fit... |
||
27 | * also see: https://www.paymentexpress.com/About/Artwork_Downloads |
||
28 | * also see: https://www.paymentexpress.com/About/About_DPS/Privacy_Policy |
||
29 | * @var String |
||
30 | */ |
||
31 | private static $stripe_logo_and_link = ' |
||
32 | <div>Stripe Logos go here...</div> |
||
33 | '; |
||
34 | |||
35 | /** |
||
36 | * we use yes / no as this is more reliable than a boolean value |
||
37 | * for configs |
||
38 | * @var String |
||
39 | */ |
||
40 | private static $is_test = "yes"; |
||
41 | |||
42 | /** |
||
43 | * we use yes / no as this is more reliable than a boolean value |
||
44 | * for configs |
||
45 | * @var boolean |
||
46 | */ |
||
47 | private static $is_live = "no"; |
||
48 | |||
49 | /** |
||
50 | * Incomplete (default): Payment created but nothing confirmed as successful |
||
51 | * Success: Payment successful |
||
52 | * Failure: Payment failed during process |
||
53 | * Pending: Payment awaiting receipt/bank transfer etc |
||
54 | */ |
||
55 | private static $db = array( |
||
56 | "StripeID" => "Varchar(64)", |
||
57 | "CardNumber" => "Varchar(19)", |
||
58 | "NameOnCard" => "Varchar(40)", |
||
59 | "ExpiryDate" => "Varchar(4)", |
||
60 | "CVVNumber" => "Varchar(3)", |
||
61 | "Request" => "Text", |
||
62 | "Response" => "Text", |
||
63 | "IdemPotencyKey" => "Text" |
||
64 | ); |
||
65 | |||
66 | private static $casting = array( |
||
67 | "RequestDetails" => "HTMLText", |
||
68 | "ResponseDetails" => "HTMLText" |
||
69 | ); |
||
70 | |||
71 | private static $indexes = array( |
||
72 | "StripeID" => true |
||
73 | ); |
||
74 | |||
75 | public function getCMSFields() |
||
84 | |||
85 | /** |
||
86 | * Return the payment form fields that should |
||
87 | * be shown on the checkout order form for the |
||
88 | * payment type. Example: for {@link DPSPayment}, |
||
89 | * this would be a set of fields to enter your |
||
90 | * credit card details. |
||
91 | * |
||
92 | * @return FieldList |
||
93 | */ |
||
94 | public function getPaymentFormFields() |
||
104 | |||
105 | /** |
||
106 | * Define what fields defined in {@link Order->getPaymentFormFields()} |
||
107 | * should be required. |
||
108 | * |
||
109 | * @see DPSPayment->getPaymentFormRequirements() for an example on how |
||
110 | * this is implemented. |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | public function getPaymentFormRequirements() |
||
119 | |||
120 | /** |
||
121 | * returns true if all the data is correct. |
||
122 | * |
||
123 | * @param array $data The form request data - see OrderForm |
||
124 | * @param OrderForm $form The form object submitted on |
||
125 | * |
||
126 | * @return Boolean |
||
127 | */ |
||
128 | public function validatePayment($data, $form) |
||
133 | |||
134 | /** |
||
135 | * Perform payment processing for the type of |
||
136 | * payment. For example, if this was a credit card |
||
137 | * payment type, you would perform the data send |
||
138 | * off to the payment gateway on this function for |
||
139 | * your payment subclass. |
||
140 | * |
||
141 | * This is used by {@link OrderForm} when it is |
||
142 | * submitted. |
||
143 | * |
||
144 | * @param array $data The form request data - see OrderForm |
||
145 | * @param OrderForm $form The form object submitted on |
||
146 | * |
||
147 | * @return EcommercePaymentResult |
||
148 | */ |
||
149 | public function processPayment($data, $form) |
||
189 | |||
190 | /** |
||
191 | * |
||
192 | * @return string (HTML) |
||
193 | */ |
||
194 | public function getRequestDetails() |
||
198 | |||
199 | /** |
||
200 | * |
||
201 | * @return string (HTML) |
||
202 | */ |
||
203 | public function myResponseDetails() |
||
207 | |||
208 | /** |
||
209 | * @var Order |
||
210 | */ |
||
211 | protected $_processing_order = null; |
||
212 | |||
213 | /** |
||
214 | * @var float |
||
215 | */ |
||
216 | protected $_processing_amount = 0; |
||
217 | |||
218 | /** |
||
219 | * @var string |
||
220 | */ |
||
221 | protected $_processing_currency = 0; |
||
222 | |||
223 | /** |
||
224 | * @var int |
||
225 | */ |
||
226 | protected $_processing_year = 0; |
||
227 | |||
228 | /** |
||
229 | * @var int |
||
230 | */ |
||
231 | protected $_processing_month = 0; |
||
232 | |||
233 | /** |
||
234 | * @var string |
||
235 | */ |
||
236 | protected $_processing_statement_description = ""; |
||
237 | |||
238 | /** |
||
239 | * @var array |
||
240 | */ |
||
241 | protected $_processing_metadata = array(); |
||
242 | |||
243 | /** |
||
244 | * |
||
245 | * |
||
246 | */ |
||
247 | protected function retrieveVariables() |
||
288 | |||
289 | /** |
||
290 | * |
||
291 | * |
||
292 | */ |
||
293 | protected function instantiateAPI() |
||
298 | |||
299 | /** |
||
300 | * remove the card details |
||
301 | * for securityu reasons |
||
302 | */ |
||
303 | protected function removeCardDetails() |
||
310 | |||
311 | /** |
||
312 | * is the full credit card recorded? |
||
313 | * @return boolean |
||
314 | */ |
||
315 | protected function hasFullCardNumber() |
||
319 | |||
320 | /** |
||
321 | * @param mixed $requestData; |
||
322 | * @param mixed $responseData; |
||
323 | */ |
||
324 | protected function recordTransaction($requestData, $responseData) |
||
338 | } |
||
339 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.