-
Notifications
You must be signed in to change notification settings - Fork 4
/
commerce_paypal_chained.install
388 lines (379 loc) · 10.1 KB
/
commerce_paypal_chained.install
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
/**
* @file
* Installs the tables required by Commerce PayPal Chained.
*/
/**
* Implements hook_schema().
*/
function commerce_paypal_chained_schema() {
$schema = array();
$schema['commerce_paypal_chained_ipn'] = array(
'description' => 'Stores processed IPNs.',
'fields' => array(
'ipn_id' => array(
'description' => 'Serial numeric ID of the IPN in the local database.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pay_key' => array(
'description' => 'The PayPal pay key associated with this chained payment.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'transaction_type' => array(
'description' => 'The PayPal transaction type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'sender_email' => array(
'description' => 'The e-mail of the payer.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'order_id' => array(
'description' => 'The order ID the payment belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'The status of the payment at PayPal.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'fees_payer' => array(
'description' => 'The payer of the PayPal fees.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the IPN was received.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the IPN was last updated.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'test_ipn' => array(
'description' => 'Boolean indicating whether or not this was a test IPN sent by the Sandbox.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('ipn_id'),
'foreign keys' => array(
'order_id' => array(
'table' => 'commerce_order',
'columns'=> array('order_id' => 'order_id'),
),
),
'indexes' => array(
'pay_key' => array('pay_key'),
),
);
$schema['commerce_paypal_chained_ipn_transaction'] = array(
'description' => 'Stores processed IPN transactions.',
'fields' => array(
'ipn_transaction_id' => array(
'description' => 'Serial numeric ID of the IPN transaction in the local database.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'ipn_id' => array(
'description' => 'The IPN ID the ipn transaction belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'transaction_id' => array(
'description' => 'The payment transaction ID the ipn transaction belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'id' => array(
'description' => 'The PayPal transaction ID.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'is_primary_receiver' => array(
'description' => 'Whether or not the receiver specified here is the primary receiver.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'receiver' => array(
'description' => 'The e-mail of the receiver.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'amount' => array(
'description' => 'The payment amount of the transaction (eg. "USD 5.90").',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'gross' => array(
'description' => 'The gross transaction amount.',
'type' => 'numeric',
'size' => 'normal',
'precision' => 10,
'scale' => 2,
'not null' => TRUE,
'default' => 0,
),
'currency' => array(
'description' => 'The currency code of the transaction.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'status' => array(
'description' => 'The status of the transaction at PayPal.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('ipn_transaction_id'),
'foreign keys' => array(
'ipn_id' => array(
'table' => 'commerce_paypal_chained_ipn',
'columns'=> array('ipn_id' => 'ipn_id'),
),
'transaction_id' => array(
'table' => 'commerce_payment_transaction',
'columns'=> array('payment_id' => 'payment_id'),
),
),
'indexes' => array(
'ipn_id' => array('ipn_id'),
),
);
$schema['commerce_paypal_chained_pay_chain'] = array(
'description' => 'Stores pay chains associated with orders.',
'fields' => array(
'pay_chain_id' => array(
'description' => 'Serial numeric ID of the pay chain in the local database.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'order_id' => array(
'description' => 'The order ID the pay chain belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'pay_key' => array(
'description' => 'The PayPal pay key associated with this pay chain.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'currency' => array(
'description' => 'The currency code of the pay chain.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array representing the pay chain.',
),
),
'primary key' => array('pay_chain_id'),
'foreign keys' => array(
'order_id' => array(
'table' => 'commerce_order',
'columns'=> array('order_id' => 'order_id'),
),
),
'indexes' => array(
'order_id' => array('order_id'),
'pay_key' => array('pay_key'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function commerce_paypal_chained_install() {
// Define the payment receiver field and create it
$field = array (
'translatable' => '0',
'entity_types' =>
array (
),
'settings' =>
array (
'max_length' => '255',
),
'storage' =>
array (
'type' => 'field_sql_storage',
'settings' =>
array (
),
'module' => 'field_sql_storage',
'active' => '1',
'details' =>
array (
'sql' =>
array (
'FIELD_LOAD_CURRENT' =>
array (
'field_data_field_chained_receiver_email' =>
array (
'value' => 'field_chained_receiver_email_value',
'format' => 'field_chained_receiver_email_format',
),
),
'FIELD_LOAD_REVISION' =>
array (
'field_revision_field_chained_receiver_email' =>
array (
'value' => 'field_chained_receiver_email_value',
'format' => 'field_chained_receiver_email_format',
),
),
),
),
),
'foreign keys' =>
array (
'format' =>
array (
'table' => 'filter_format',
'columns' =>
array (
'format' => 'format',
),
),
),
'indexes' =>
array (
'format' =>
array (
0 => 'format',
),
),
'id' => '48',
'field_name' => 'field_chained_receiver_email',
'type' => 'text',
'module' => 'text',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' =>
array (
'value' =>
array (
'type' => 'varchar',
'length' => '255',
'not null' => false,
),
'format' =>
array (
'type' => 'varchar',
'length' => 255,
'not null' => false,
),
),
'bundles' =>
array (
'commerce_payment_transaction' =>
array (
0 => 'commerce_payment_transaction',
),
),
);
field_create_field($field);
// Create an instance of our field on the commerce_payment_transaction entity
$field_instance = array (
'label' => 'Receiver Email Address',
'widget' =>
array (
'weight' => '-3',
'type' => 'text_textfield',
'module' => 'text',
'active' => 1,
'settings' =>
array (
'size' => '60',
),
),
'settings' =>
array (
'text_processing' => '0',
'user_register_form' => false,
),
'display' =>
array (
'default' =>
array (
'label' => 'above',
'type' => 'text_default',
'settings' =>
array (
),
'module' => 'text',
'weight' => -3,
),
),
'required' => 0,
'description' => '',
'fences_wrapper' => '',
'default_value' => NULL,
'field_name' => 'field_chained_receiver_email',
'entity_type' => 'commerce_payment_transaction',
'bundle' => 'paypal_chained',
'deleted' => '0',
);
field_create_instance($field_instance);
}
/**
* Implements hook_uninstall().
*/
function commerce_paypal_chained_uninstall() {
// Queue up our field_chained_receiver_email field for deletion.
field_delete_field('field_chained_receiver_email');
}