forked from drewjoh/phpPayPal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpPayPal.php
1718 lines (1512 loc) · 87 KB
/
phpPayPal.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
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Created by Drew Johnston, 2007, drewjoh.com
Please give credit where credit is due. :)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Initial code for Get, Create and Update Recurring Payment Profiles methods available thanks to Bill Joslin (billjoslin.com).
*/
class phpPayPal {
private $sandbox = true;
private $live = false;
private $API_ENDPOINT = null;
private $PAYPAL_URL = null;
public $API_USERNAME = null;
public $API_PASSWORD = null;
public $API_SIGNATURE = null;
public $USE_PROXY = null;
public $PROXY_HOST = null;
public $PROXY_PORT = null;
public $return_url = null;
public $cancel_url = null;
public $VERSION = '53.0';
// ----------------------------
// PUBLIC VARIABLES
// ----------------------------
// Array of the response variables from PayPal requests
public $Response;
/* -------------------
ERROR VARIABLES
-------------------
- $Error = an array of PayPal's response to any paypal errors
- All $_error's = are filled for any error that occurs, including PayPal errors
- If a method returns false, the $_error's should be filled with error information
*/
// Array of the error response from PayPal - [TIMESTAMP] [CORRELATIONID] [ACK] [L_ERRORCODE0] [L_SHORTMESSAGE0] [L_LONGMESSAGE0] [L_SEVERITYCODE0] [VERSION] [BUILD]
public $Error;
public $_error = false;
public $_error_ack;
public $_error_type;
public $_error_date;
public $_error_code;
public $_error_short_message;
public $_error_long_message;
public $_error_corrective_action;
public $_error_severity_code;
public $_error_version;
public $_error_build;
public $_error_display_message;
/* ----------------------
REQUEST VARIABLES
----------------------
- All values found in a Request
- Format is $our_variable_name; // PAYPALS_VARIABLE_NAME
*/
public $payment_type = 'Sale'; // PAYMENTTYPE
public $email; // EMAIL
public $salutation; // SALUTATION
public $first_name; // FIRSTNAME
public $middle_name; // MIDDLENAME
public $last_name; // LASTNAME
public $suffix; // SUFFIX
public $credit_card_type; // CREDITCARDTYPE --- Visa, MasterCard, Discover, Amex, Switch, Solo
public $credit_card_number; // ACCT
public $expire_date; // EXPDATE - MMYYYY
public $cvv2_code; // CVV2
public $address1; // STREET
public $address2; // STREET2
public $city; // CITY
public $state; // STATE
public $postal_code; // ZIP
public $phone_number; // PHONENUM
public $country_code; // COUNTRYCODE
public $currency_code = "USD"; // CURRENCYCODE
public $ip_address; //IPADDRESS
public $amount_total; // AMT
public $amount_shipping; // SHIPPINGAMT
public $amount_handling; // HANDLINGAMT
public $amount_tax; // TAXAMT
public $amount_sales_tax; // SALESTAX - This is apparently only used with getTransactionDetails, and appears to be the same as amount_tax
public $amount_items; // ITEMAMT
public $amount_max; // MAXAMT
public $amount_fee; // FEEAMT
public $amount_settle; // SETTLEAMT
public $amount_refund_net; // NETREFUNDAMT
public $amount_refund_fee; // FEEREFUNDAMT
public $amount_refund_total; // GROSSREFUNDAMT
public $billing_type;
public $billing_agreement;
public $shipping_name; // SHIPTONAME
public $shipping_address1; // SHIPTOSTREET
public $shipping_address2; // SHIPTOSTREET2
public $shipping_city; // SHIPTOCITY
public $shipping_state; // SHIPTOSTATE
public $shipping_postal_code; // SHIPTOZIP
public $shipping_country_code; // SHIPTOCOUNTRYCODE
public $shipping_country_name;
public $shipping_phone_number; // SHIPTOPHONENUM
public $description; // DESC
public $custom; // CUSTOM
public $invoice_number; // INVNUM
public $note; // NOTE
public $notify_url; // NOTIFYURL
public $require_confirmed_shipping_address; // REQCONFIRMSHIPPING
public $no_shipping; // NOSHIPPING
public $address_override; // ADDROVERRIDE
public $local_code; // LOCALECODE
public $page_style; // PAGESTYLE
public $hdr_image; // HDRIMG
public $hdr_border_color; //HDRBORDERCOLOR
public $hdr_back_color; // HDRBACKCOLOR
public $payflow_color; // PAYFLOWCOLOR
public $channel_type; // CHANNELTYPE
public $solution_type; // SOLUTIONTYPE
public $user_action; // USERACTION
public $return_fmf_details = 0; // RETURNFMFDETAILS - 0 by default
// Variables found in Authorize and Capture
public $authorization_id; // AUTHORIZATIONID
public $complete_type; // COMPLETETYPE
public $soft_descriptor; // SOFTDESCRIPTOR
public $transaction_entity; // TRANSACTIONENTITY
// Recurring Payments
public $profile_start_date;
public $billing_period;
public $billing_frequency;
public $billing_amount;
// Variables that are returned to us
public $ack;
public $token; // TOKEN
public $payer_id; // PAYERID
public $payer_status; // PAYERSTATUS
public $payer_business; // PAYERBUSINESS
public $address_owner; // ADDRESSOWNER
public $address_status; // ADDRESSSTATUS
public $address_id;
public $business; // BUSINESS
public $avs_code;
public $cvv2_match;
public $transaction_id; // TRANSACTIONID
public $parent_transaction_id; // PARENTTRANSACTIONID
public $refund_transaction_id; // REFUNDTRANSACTIONID
public $transaction_type; // TRANSACTIONTYPE
public $payment_status; // PAYMENTSTATUS
public $payment_pending_reason; // PENDINGREASON
public $payment_reason_code; // REASONCODE
public $order_time; // ORDERTIME
public $timestamp;
public $exchange_rate; // EXCHANGERATE
public $receipt_id; // RECEIPTID
public $receiver_business; // RECEIVERBUSINESS
public $receiver_email; // RECEIVEREMAIL
public $receiver_id; // RECEIVERID
public $subscription_id; // SUBSCRIPTIONID
public $subscription_date; // SUBSCRIPTIONDATE
public $effective_date; // EFFECTIVEDATE
public $retry_time; // RETRYTIME
public $user_name; // USERNAME
public $password; // PASSWORD
public $recurrences; // RECURRENCES
public $reattempt; // REATTEMPT
public $recurring; // RECURRING
public $period; // PERIOD
public $buyer_id; // BUYERID
public $closing_date; // CLOSINGDATE
public $multi_item; // MULTIITEM
public $refund_type; // REFUNDTYPE
// Other
public $build;
public $version;
public $correlation_id;
/*
This is the Items array, contains KEY => VALUE pairs for NAME => VALUE of items where NAME = name of item variable
Names include: name, number, quantity, amount_tax, amount_total
*/
public $ItemsArray;
/* -----------------------
COUNTRY NAMES & CODES
-----------------------
- This is an array of country names and their country codes
- Organized in CODE => NAME format ($countries[COUNTRY_CODE] = COUNTRY_NAME)
- This is purely for informational purposes, the class itself doesn't use these.
- PayPal does use the country CODES when sending address information; can come in very handy then.
- List should include all countries that PayPal accepts payments from.
*/
public $countries = array ("US"=>"United States","AL"=>"Albania","DZ"=>"Algeria","AS"=>"American Samoa","AD"=>"Andorra","AI"=>"Anguilla","AG"=>"Antigua and Barbuda","AR"=>"Argentina","AM"=>"Armenia","AW"=>"Aruba","AU"=>"Australia","AT"=>"Austria","AZ"=>"Azerbaijan Republic","BS"=>"Bahamas","BH"=>"Bahrain","BD"=>"Bangladesh","BB"=>"Barbados","BY"=>"Belarus","BE"=>"Belgium","BZ"=>"Belize","BJ"=>"Benin","BM"=>"Bermuda","BO"=>"Bolivia","BA"=>"Bosnia and Herzegovina","BW"=>"Botswana","BR"=>"Brazil","VG"=>"British Virgin Islands","BN"=>"Brunei","BG"=>"Bulgaria","BF"=>"Burkina Faso","KH"=>"Cambodia","CM"=>"Cameroon","CA"=>"Canada","CV"=>"Cape Verde","KY"=>"Cayman Islands","CL"=>"Chile","C2"=>"China","CO"=>"Colombia","CK"=>"Cook Islands","CR"=>"Costa Rica","CI"=>"Cote D'Ivoire","HR"=>"Croatia","CY"=>"Cyprus","CZ"=>"Czech Republic","DK"=>"Denmark","DJ"=>"Djibouti","DM"=>"Dominica","DO"=>"Dominican Republic","TP"=>"East Timor","EC"=>"Ecuador","EG"=>"Egypt","SV"=>"El Salvador","EE"=>"Estonia","FM"=>"Federated States of Micronesia","FJ"=>"Fiji","FI"=>"Finland","FR"=>"France","GF"=>"French Guiana","PF"=>"French Polynesia","GA"=>"Gabon Republic","GE"=>"Georgia","DE"=>"Germany","GH"=>"Ghana","GI"=>"Gibraltar","GR"=>"Greece","GD"=>"Grenada","GP"=>"Guadeloupe","GU"=>"Guam","GT"=>"Guatemala","GN"=>"Guinea","GY"=>"Guyana","HT"=>"Haiti","HN"=>"Honduras","HK"=>"Hong Kong","HU"=>"Hungary","IS"=>"Iceland","IN"=>"India","ID"=>"Indonesia","IE"=>"Ireland","IL"=>"Israel","IT"=>"Italy","JM"=>"Jamaica","JP"=>"Japan","JO"=>"Jordan","KZ"=>"Kazakhstan","KE"=>"Kenya","KW"=>"Kuwait","LA"=>"Laos","LV"=>"Latvia","LB"=>"Lebanon","LS"=>"Lesotho","LT"=>"Lithuania","LU"=>"Luxembourg","MO"=>"Macau","MK"=>"Macedonia","MG"=>"Madagascar","MY"=>"Malaysia","MV"=>"Maldives","ML"=>"Mali","MT"=>"Malta","MH"=>"Marshall Islands","MQ"=>"Martinique","MU"=>"Mauritius","MX"=>"Mexico","MD"=>"Moldova","MN"=>"Mongolia","MS"=>"Montserrat","MA"=>"Morocco","MZ"=>"Mozambique","NA"=>"Namibia","NP"=>"Nepal","NL"=>"Netherlands","AN"=>"Netherlands Antilles","NZ"=>"New Zealand","NI"=>"Nicaragua","MP"=>"Northern Mariana Islands","NO"=>"Norway","OM"=>"Oman","PK"=>"Pakistan","PW"=>"Palau","PS"=>"Palestine","PA"=>"Panama","PG"=>"Papua New Guinea","PY"=>"Paraguay","PE"=>"Peru","PH"=>"Philippines","PL"=>"Poland","PT"=>"Portugal","PR"=>"Puerto Rico","QA"=>"Qatar","RO"=>"Romania","RU"=>"Russia","RW"=>"Rwanda","VC"=>"Saint Vincent and the Grenadines","WS"=>"Samoa","SA"=>"Saudi Arabia","SN"=>"Senegal","CS"=>"Serbia and Montenegro","SC"=>"Seychelles","SG"=>"Singapore","SK"=>"Slovakia","SI"=>"Slovenia","SB"=>"Solomon Islands","ZA"=>"South Africa","KR"=>"South Korea","ES"=>"Spain","LK"=>"Sri Lanka","KN"=>"St. Kitts and Nevis","LC"=>"St. Lucia","SZ"=>"Swaziland","SE"=>"Sweden","CH"=>"Switzerland","TW"=>"Taiwan","TZ"=>"Tanzania","TH"=>"Thailand","TG"=>"Togo","TO"=>"Tonga","TT"=>"Trinidad and Tobago","TN"=>"Tunisia","TR"=>"Turkey","TM"=>"Turkmenistan","TC"=>"Turks and Caicos Islands","UG"=>"Uganda","UA"=>"Ukraine","AE"=>"United Arab Emirates","GB"=>"United Kingdom","UY"=>"Uruguay","UZ"=>"Uzbekistan","VU"=>"Vanuatu","VE"=>"Venezuela","VN"=>"Vietnam","VI"=>"Virgin Islands (USA)","YE"=>"Yemen","ZM"=>"Zambia");
/* --------------------
STATES
--------------------
- States for certain countries, many of these are required formats for PayPal
- Multidimensional array
- $states[COUNTRY_CODE][STATE_CODE] = STATE_NAME
*/
public $states = array(
'US' => array ("AK"=>"AK","AL"=>"AL","AR"=>"AR","AZ"=>"AZ","CA"=>"CA","CO"=>"CO","CT"=>"CT","DC"=>"DC","DE"=>"DE","FL"=>"FL","GA"=>"GA","HI"=>"HI",
"IA"=>"IA","ID"=>"ID","IL"=>"IL","IN"=>"IN","KS"=>"KS","KY"=>"KY","LA"=>"LA","MA"=>"MA","MD"=>"MD","ME"=>"ME","MI"=>"MI","MN"=>"MN",
"MO"=>"MO","MS"=>"MS","MT"=>"MT","NC"=>"NC","ND"=>"ND","NE"=>"NE","NH"=>"NH","NJ"=>"NJ","NM"=>"NM","NV"=>"NV","NY"=>"NY","OH"=>"OH",
"OK"=>"OK","OR"=>"OR","PA"=>"PA","RI"=>"RI","SC"=>"SC","SD"=>"SD","TN"=>"TN","TX"=>"TX","UT"=>"UT","VA"=>"VA","VT"=>"VT","WA"=>"WA",
"WI"=>"WI","WV"=>"WV","WY"=>"WY","AA"=>"AA","AE"=>"AE","AP"=>"AP","AS"=>"AS","FM"=>"FM","GU"=>"GU","MH"=>"MH","MP"=>"MP","PR"=>"PR",
"PW"=>"PW","VI"=>"VI")
,
'CA' => array ("AB"=>"Alberta", "BC"=>"British Columbia", "MB"=>"Manitoba", "NB"=>"New Brunswick", "NL"=>"Newfoundland", "NS"=>"Nova Scotia",
"NU"=>"Nunavut", "NT"=>"Northwest Territories", "ON"=>"Ontario", "PE"=>"Prince Edward Island", "QC"=>"Quebec", "SK"=>"Saskatchewan",
"YT"=>"Yukon")
,
'AU' => array ("Australian Capital Territory"=>"Australian Capital Territory","New South Wales"=>"New South Wales","Northern Territory"=>"Northern Territory",
"Queensland"=>"Queensland","South Australia"=>"South Australia","Tasmania"=>"Tasmania","Victoria"=>"Victoria","Western Australia"=>"Western Australia")
,
'GB' => array ("Aberdeen City"=>"Aberdeen City","Aberdeenshire"=>"Aberdeenshire","Angus"=>"Angus","Antrim"=>"Antrim","Argyll and Bute"=>"Argyll and Bute",
"Armagh"=>"Armagh","Avon"=>"Avon","Bedfordshire"=>"Bedfordshire","Berkshire"=>"Berkshire","Blaenau Gwent"=>"Blaenau Gwent","Borders"=>"Borders",
"Bridgend"=>"Bridgend","Bristol"=>"Bristol","Buckinghamshire"=>"Buckinghamshire","Caerphilly"=>"Caerphilly","Cambridgeshire"=>"Cambridgeshire",
"Cardiff"=>"Cardiff","Carmarthenshire"=>"Carmarthenshire","Ceredigion"=>"Ceredigion","Channel Islands"=>"Channel Islands","Cheshire"=>"Cheshire",
"Clackmannan"=>"Clackmannan","Cleveland"=>"Cleveland","Conwy"=>"Conwy","Cornwall"=>"Cornwall","Cumbria"=>"Cumbria","Denbighshire"=>"Denbighshire",
"Derbyshire"=>"Derbyshire","Devon"=>"Devon","Dorset"=>"Dorset","Down"=>"Down","Dumfries and Galloway"=>"Dumfries and Galloway","Durham"=>"Durham",
"East Ayrshire"=>"East Ayrshire","East Dunbartonshire"=>"East Dunbartonshire","East Lothian"=>"East Lothian","East Renfrewshire"=>"East Renfrewshire",
"East Riding of Yorkshire"=>"East Riding of Yorkshire","East Sussex"=>"East Sussex","Edinburgh City"=>"Edinburgh City","Essex"=>"Essex",
"Falkirk"=>"Falkirk","Fermanagh"=>"Fermanagh","Fife"=>"Fife","Flintshire"=>"Flintshire","Glasgow"=>"Glasgow","Gloucestershire"=>"Gloucestershire",
"Greater Manchester"=>"Greater Manchester","Gwynedd"=>"Gwynedd","Hampshire"=>"Hampshire","Herefordshire"=>"Herefordshire",
"Hertfordshire"=>"Hertfordshire","Highland"=>"Highland","Humberside"=>"Humberside","Inverclyde"=>"Inverclyde","Isle of Anglesey"=>"Isle of Anglesey",
"Isle of Man"=>"Isle of Man","Isle of Wight"=>"Isle of Wight","Isles of Scilly"=>"Isles of Scilly","Kent"=>"Kent","Lancashire"=>"Lancashire",
"Leicestershire"=>"Leicestershire","Lincolnshire"=>"Lincolnshire","London"=>"London","Londonderry"=>"Londonderry","Merseyside"=>"Merseyside",
"Merthyr Tydfil"=>"Merthyr Tydfil","Middlesex"=>"Middlesex","Midlothian"=>"Midlothian","Monmouthshire"=>"Monmouthshire","Moray"=>"Moray",
"Neath Port Talbot"=>"Neath Port Talbot","Newport"=>"Newport","Norfolk"=>"Norfolk","North Ayrshire"=>"North Ayrshire",
"North Lanarkshire"=>"North Lanarkshire","North Yorkshire"=>"North Yorkshire","Northamptonshire"=>"Northamptonshire","Northumberland"=>"Northumberland",
"Nottinghamshire"=>"Nottinghamshire","Orkney"=>"Orkney","Oxfordshire"=>"Oxfordshire","Pembrokeshire"=>"Pembrokeshire",
"Perthshire and Kinross"=>"Perthshire and Kinross","Powys"=>"Powys","Renfrewshire"=>"Renfrewshire","Rhondda Cynon Taff"=>"Rhondda Cynon Taff",
"Rutland"=>"Rutland","Shetland"=>"Shetland","Shropshire"=>"Shropshire","Somerset"=>"Somerset","South Ayrshire"=>"South Ayrshire",
"South Lanarkshire"=>"South Lanarkshire","South Yorkshire"=>"South Yorkshire","Staffordshire"=>"Staffordshire","Stirling"=>"Stirling",
"Suffolk"=>"Suffolk","Surrey"=>"Surrey","Swansea"=>"Swansea","The Vale of Glamorgan"=>"The Vale of Glamorgan","Tofaen"=>"Tofaen",
"Tyne and Wear"=>"Tyne and Wear","Tyrone"=>"Tyrone","Warwickshire"=>"Warwickshire","West Dunbartonshire"=>"West Dunbartonshire",
"West Lothian"=>"West Lothian","West Midlands"=>"West Midlands","West Sussex"=>"West Sussex","West Yorkshire"=>"West Yorkshire",
"Western Isles"=>"Western Isles","Wiltshire"=>"Wiltshire","Worcestershire"=>"Worcestershire","Wrexham"=>"Wrexham")
,
'ES' => array ("Alava" => "Alava", "Albacete" => "Albacete", "Alicante" => "Alicante", "Almeria" => "Almeria", "Asturias" => "Asturias",
"Avila" => "Avila", "Badajoz" => "Badajoz", "Barcelona" => "Barcelona", "Burgos" => "Burgos", "Caceres" => "Caceres",
"Cadiz" => "Cadiz", "Cantabria" => "Cantabria", "Castellon" => "Castellon", "Ceuta" => "Ceuta", "Ciudad Real" => "Ciudad Real",
"Cordoba" => "Cordoba", "Cuenca" => "Cuenca", "Guadalajara" => "Guadalajara", "Gerona" => "Gerona", "Granada" => "Granada",
"Guipuzcoa" => "Guipuzcoa", "Huelva" => "Huelva", "Huesca" => "Huesca", "Islas Baleares" => "Islas Baleares", "Jaen" => "Jaen",
"La Coruna" => "La Coruna", "Las Palmas" => "Las Palmas", "La Rioja" => "La Rioja", "Leon" => "Leon", "Lerida" => "Lerida",
"Lugo" => "Lugo", "Madrid" => "Madrid", "Malaga" => "Malaga", "Melilla" => "Melilla", "Murcia" => "Murcia", "Navarra" => "Navarra",
"Orense" => "Orense", "Palencia" => "Palencia", "Pontevedra" => "Pontevedra", "Salamanca" => "Salamanca",
"Santa Cruz de Tenerife" => "Santa Cruz de Tenerife", "Segovia" => "Segovia", "Sevilla" => "Sevilla", "Soria" => "Soria",
"Tarragona" => "Tarragona", "Teruel" => "Teruel", "Toledo" => "Toledo", "Valencia" => "Valencia", "Valladolid" => "Valladolid",
"Vizcaya" => "Vizcaya", "Zamora" => "Zamora", "Zaragoza" => "Zaragoza")
);
// ----------------------------
// Internal Use Varibles
// ----------------------------
/* -----------------------------------------
AVS Response Code Values and Meanings
-----------------------------------------
- $AvsResponseCodesArray[CODE][MESSAGE]
- $AvsResponseCodesArray[CODE][DETAILS]
*/
public $AvsResponseCodesArray = array (
'A' => array('message' => 'Address', 'details' => 'Address Only (no ZIP)'),
'B' => array('message' => 'International "A"', 'details' => 'Address Only (no ZIP)'),
'C' => array('message' => 'International "N"', 'details' => 'None - The transaction is declined.'),
'D' => array('message' => 'International "X"', 'details' => 'Address and Postal Code'),
'E' => array('message' => 'Not Allowed for MOTO (Internet/Phone) transactions', 'details' => 'Not applicable - The transaction is declined.'),
'F' => array('message' => 'UK-Specific "X"', 'details' => 'Address and Postal Code'),
'G' => array('message' => 'Global Unavailable', 'details' => 'Not applicable'),
'I' => array('message' => 'International Unavailable', 'details' => 'Not applicable'),
'N' => array('message' => 'No', 'details' => 'None - The transaction is declined.'),
'P' => array('message' => 'Postal (International "Z")', 'details' => 'Postal Code only (no Address)'),
'R' => array('message' => 'Retry', 'details' => 'Not Applicable'),
'S' => array('message' => 'Service Not Supported', 'details' => 'Not Applicable'),
'U' => array('message' => 'Unavailable', 'details' => 'Not Applicable'),
'W' => array('message' => 'Whole ZIP', 'details' => 'Nine-digit ZIP code (no Address)'),
'X' => array('message' => 'Exact Match', 'details' => 'Address and nine-digit ZIP code'),
'Y' => array('message' => 'Yes', 'details' => 'Address and five-digit ZIP'),
'Z' => array('message' => 'ZIP', 'details' => 'Five-digit ZIP code (no Address)'),
'' => array('message' => 'Error', 'details' => 'Not Applicable')
);
/* ---------------------------------------
CVV Rsponse Code Values and Meanings
---------------------------------------
- $CvvResponseCodesArray[CODE][MESSAGE]
- $CvvResponseCodesArray[CODE][DETAILS]
*/
public $CvvResponseCodesArray = array (
'M' => array('message' => 'Match', 'details' => 'CVV2'),
'N' => array('message' => 'No Match', 'details' => 'None'),
'P' => array('message' => 'Not Processed', 'details' => 'Not Applicable'),
'S' => array('message' => 'Service not supported', 'details' => 'Not Applicable'),
'U' => array('message' => 'Service not available', 'details' => 'Not Applicable'),
'X' => array('message' => 'No response', 'details' => 'Not Applicable')
);
/* ---------------------------------------
CVV Rsponse Code Values and Meanings for Switch and Solo cards
---------------------------------------
- TODO: ??
*/
/* --------------------------------------------
REQUEST FIELDS ARRAYS
--------------------------------------------
*/
public $RequestFieldsArray = array(
'DoCapture' => array(
'authorization_id' => array('name' =>'AUTHORIZATIONID', 'required' => 'yes'),
'amount' => array('name' =>'AMT', 'required' => 'yes'),
'currency_code' => array('name' =>'CURRENCYCODE', 'required' => 'no'),
'complete_type' => array('name' =>'COMPLETETYPE', 'required' => 'yes'),
'invoice_number' => array('name' =>'INVNUM', 'required' => 'no'),
'note' => array('name' =>'NOTE', 'required' => 'no'),
'soft_descriptor' => array('name' =>'SOFTDESCRIPTOR', 'required' => 'no')
),
'DoAuthorization' => array(
'transaction_id' => array('name' =>'TRANSACTIONID', 'required' => 'yes'),
'amount' => array('name' =>'AMT', 'required' => 'yes'),
'transaction_entity' => array('name' =>'TRANSACTIONENTITY', 'required' => 'no'),
'currency_code' => array('name' =>'CURRENCYCODE', 'required' => 'no')
),
'DoReauthorization' => array(
'authorization_id' => array('name' =>'AUTHORIZATIONID', 'required' => 'yes'),
'amount' => array('name' =>'AMT', 'required' => 'yes')
),
'DoVoid' => array(
'authorization_id' => array('name' =>'AUTHORIZATIONID', 'required' => 'yes'),
'note' => array('name' =>'NOTE', 'required' => 'no')
),
'DoDirectPayment' => array(
'payment_type' => array('name' => 'PAYMENTACTION', 'required' => 'yes'),
'ip_address' => array('name' => 'IPADDRESS', 'required' => 'yes'),
'return_fmf_details' => array('name' => 'RETURNFMFDETAILS', 'required' => 'no'),
'amount_total' => array('name' => 'AMT', 'required' => 'yes'),
'credit_card_type' => array('name' => 'CREDITCARDTYPE', 'required' => 'yes'),
'credit_card_number' => array('name' => 'ACCT', 'required' => 'yes'),
'expire_date' => array('name' => 'EXPDATE', 'required' => 'yes'),
'first_name' => array('name' => 'FIRSTNAME', 'required' => 'yes'),
'last_name' => array('name' => 'LASTNAME', 'required' => 'yes'),
'address1' => array('name' => 'STREET', 'required' => 'no'),
'address2' => array('name' => 'STREET2', 'required' => 'no'),
'city' => array('name' => 'CITY', 'required' => 'no'),
'state' => array('name' => 'STATE', 'required' => 'no'),
'country_code' => array('name' => 'COUNTRYCODE', 'required' => 'no'),
'postal_code' => array('name' => 'ZIP', 'required' => 'no'),
'notify_url' => array('name' => 'NOTIFYURL', 'required' => 'no'),
'currency_code' => array('name' => 'CURRENCYCODE', 'required' => 'no'),
'amount_items' => array('name' => 'ITEMAMT', 'required' => 'no'),
'amount_shipping' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'amount_handling' => array('name' => 'HANDLINGAMT', 'required' => 'no'),
'amount_tax' => array('name' => 'TAXAMT', 'required' => 'no'),
'description' => array('name' => 'DESC', 'required' => 'no'),
'custom' => array('name' => 'CUSTOM', 'required' => 'no'),
'invoice_number' => array('name' => 'INVNUM', 'required' => 'no'),
'cvv2_code' => array('name' => 'CVV2', 'required' => 'yes'),
'start_date' => array('name' => 'STARTDATE', 'required' => 'no'), // For Maestro/Solo cards
'issue_number' => array('name' => 'ISSUENUMBER', 'required' => 'no'), // For maestro/Solo Cards
'email' => array('name' => 'EMAIL', 'required' => 'no'),
'phone_number' => array('name' => 'PHONENUM', 'required' => 'no'),
'shipping_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'shipping_address1' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'shipping_address2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'shipping_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'shipping_state' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'shipping_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'shipping_country_code' => array('name' => 'SHIPTOCOUNTRYCODE', 'required' => 'no'),
'shipping_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no')
),
'SetExpressCheckout' => array(
'return_url' => array('name' => 'RETURNURL', 'required' => 'yes'),
'cancel_url' => array('name' => 'CANCELURL', 'required' => 'yes'),
'amount_total' => array('name' => 'AMT', 'required' => 'yes'),
'currency_code' => array('name' => 'CURRENCYCODE', 'required' => 'no'),
'amount_max' => array('name' => 'MAXAMT', 'required' => 'no'),
'payment_type' => array('name' => 'PAYMENTACTION', 'required' => 'no'),
'email' => array('name' => 'EMAIL', 'required' => 'no'),
'description' => array('name' => 'DESC', 'required' => 'no'),
'custom' => array('name' => 'CUSTOM', 'required' => 'no'),
'invoice_number' => array('name' => 'INVNUM', 'required' => 'no'),
'phone_number' => array('name' => 'PHONENUM', 'required' => 'no'),
'shipping_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'shipping_address1' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'shipping_address2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'shipping_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'shipping_state' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'shipping_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'shipping_country_code' => array('name' => 'SHIPTOCOUNTRYCODE', 'required' => 'no'),
'shipping_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no'),
'require_confirmed_shipping_address' => array('name' => 'REQCONFIRMSHIPPING', 'required' => 'no'),
'no_shipping' => array('name' => 'NOSHIPPING', 'required' => 'no'),
'address_override' => array('name' => 'ADDROVERRIDE', 'required' => 'no'),
'token' => array('name' => 'TOKEN', 'required' => 'no'),
'locale_code' => array('name' => 'LOCALECODE', 'required' => 'no'),
'page_style' => array('name' => 'PAGESTYLE', 'required' => 'no'),
'hdr_img' => array('name' => 'HDRIMG', 'required' => 'no'),
'hdr_border_color' => array('name' => 'HDRBORDERCOLOR', 'required' => 'no'),
'hdr_background_color' => array('name' => 'HDRBACKCOLOR', 'required' => 'no'),
'payflow_color' => array('name' => 'PAYFLOWCOLOR', 'required' => 'no'),
'user_action' => array('name' => 'USERACTION', 'required' => 'no'),
'channel_type' => array('name' => 'CHANNELTYPE', 'required' => 'no'),
'solution_type' => array('name' => 'SOLUTIONTYPE', 'required' => 'no') ,
'billing_type' => array('name' => 'L_BILLINGTYPE0', 'required' => 'no'),
'billing_agreement' => array('name' => 'L_BILLINGAGREEMENTDESCRIPTION0', 'required' => 'no')
),
'GetExpressCheckoutDetails' => array(
'token' => array('name' => 'TOKEN', 'required' => 'yes')
),
'DoExpressCheckoutPayment' => array(
'token' => array('name' => 'TOKEN', 'required' => 'yes'),
'payment_type' => array('name' => 'PAYMENTACTION', 'required' => 'yes'),
'payer_id' => array('name' => 'PAYERID', 'required' => 'yes'),
'amount_total' => array('name' => 'AMT', 'required' => 'yes'),
'description' => array('name' => 'DESC', 'required' => 'no'),
'custom' => array('name' => 'CUSTOM', 'required' => 'no'),
'invoice_number' => array('name' => 'INVNUM', 'required' => 'no'),
'notify_url' => array('name' => 'NOTIFYURL', 'required' => 'no'),
'amount_items' => array('name' => 'ITEMAMT', 'required' => 'no'),
'amount_shipping' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'amount_handling' => array('name' => 'HANDLINGAMT', 'required' => 'no'),
'amount_tax' => array('name' => 'TAXAMT', 'required' => 'no'),
'currency_code' => array('name' => 'CURRENCYCODE', 'required' => 'no'),
'shipping_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'shipping_address1' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'shipping_address2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'shipping_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'shipping_state' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'shipping_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'shipping_country_code' => array('name' => 'SHIPTOCOUNTRYCODE', 'required' => 'no'),
'shipping_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no')
),
'GetTransactionDetails' => array(
'transaction_id' => array('name' => 'TRANSACTIONID', 'required' => 'yes')
),
'RefundTransaction' => array(
'transaction_id' => array('name' => 'TRANSACTIONID', 'required' => 'yes'),
'refund_type' => array('name' => 'REFUNDTYPE', 'required' => 'yes'),
'amount_total' => array('name' => 'AMT', 'required' => 'no'),
'note' => array('name' => 'NOTE', 'required' => 'no'),
),
'CreateRecurringPaymentsProfile' => array(
'token' => array('name' => 'TOKEN', 'required' => 'no'),
'payer_id' => array('name' => 'PAYERID', 'required' => 'no'),
'email' => array('name' => 'EMAIL', 'required' => 'no'),
'country_code' => array('name' => 'COUNTRYCODE', 'required' => 'no'),
'business' => array('name' => 'BUSINESS', 'required' => 'no'),
'payer_status' => array('name' => 'PAYERSTATUS', 'required' => 'no'),
'subscriber_name' => array('name' => 'SUBSCRIBERNAME', 'required' => 'no'),
'profile_reference' => array('name' => 'PROFILEREFERENCE', 'required' => 'no'),
'credit_card_type' => array('name' => 'CREDITCARDTYPE', 'required' => 'yes'),
'credit_card_number' => array('name' => 'ACCT', 'required' => 'yes'),
'expire_date' => array('name' => 'EXPDATE', 'required' => 'yes'),
'first_name' => array('name' => 'FIRSTNAME', 'required' => 'yes'),
'last_name' => array('name' => 'LASTNAME', 'required' => 'yes'),
'address1' => array('name' => 'STREET', 'required' => 'no'),
'address2' => array('name' => 'STREET2', 'required' => 'no'),
'city' => array('name' => 'CITY', 'required' => 'no'),
'state' => array('name' => 'STATE', 'required' => 'no'),
'country_code' => array('name' => 'COUNTRYCODE', 'required' => 'no'),
'postal_code' => array('name' => 'ZIP', 'required' => 'no'),
'shipping_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'shipping_address1' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'shipping_address2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'shipping_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'shipping_state' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'shipping_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'shipping_country_code' => array('name' => 'SHIPTOCOUNTRYCODE', 'required' => 'no'),
'shipping_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no'),
'description' => array('name' => 'DESC', 'required' => 'no'), // You must match the billing agreement var in set Express checkout
'currency' => array('name' => 'CURRENCYCODE', 'required' => 'no'),
'payment_type' => array('name' => 'PAYMENTACTION', 'required' => 'no'),
'billing_type' => array('name' => 'L_BILLINGTYPE0', 'required' => 'no'),
'billing_agreement' => array('name' => 'L_BILLINGAGREEMENTDESCRIPTION0', 'required' => 'no'),
'profile_start_date' => array('name' => 'PROFILESTARTDATE', 'required' => 'yes'),
'billing_period' => array('name' => 'BILLINGPERIOD', 'required' => 'yes'), // Day Week Month SemiMonth Year
'billing_frequency' => array('name' => 'BILLINGFREQUENCY', 'required' => 'yes'),
'amount' => array('name' => 'AMT', 'required' => 'yes'),
'tax_amount' => array('name' => 'TAXAMT', 'required' => 'no'),
'ship_amount' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'initial_amount' => array('name' => 'INITAMT', 'required' => 'no'),
'failed_inital_amount' => array('name' => 'FAILEDINITAMTACTION', 'required' => 'no'),
'billing_total_cycles' => array('name' => 'TOTALBILLINGCYCLES', 'required' => 'no'),
'trial_billing_period' => array('name' => 'TRIALBILLINGPERIOD', 'required' => 'no'),
'trial_billing_frequency' => array('name' => 'TRIALBILLINGFREQUENCY', 'required' => 'no'),
'trial_amount' => array('name' => 'TRIALAMT', 'required' => 'no'),
'trial_billing_cycle' => array('name' => 'TRIALTOTALBILLINGCYCLES', 'required' => 'no'),
'max_failed_attempts' => array('name' => 'MAXFAILEDPAYMENTS', 'required' => 'no'),
'auto_bill_amount' => array('name' => 'AUTOBILLOUTAMT', 'required' => 'no')
),
'UpdateRecurringPaymentsProfile' => array(
'profile_id' => array('name' => 'PROFILEID', 'required' => 'yes'),
'note' => array('name' => 'NOTE', 'required' => 'no'),
'description' => array('name' => 'DESC', 'required' => 'no'),
'subscriber_name' => array('name' => 'SUBSCRIBERNAME', 'required' => 'no'),
'profile_reference' => array('name' => 'PROFILEREFERENCE', 'required' => 'no'),
'additional_billing_cycles' => array('name' => 'ADDITIONALBILLINGCYCLES', 'required' => 'no'),
'amount' => array('name' => 'AMT', 'required' => 'yes'),
'shipping_amount' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'tax_amount' => array('name' => 'TAXAMT', 'required' => 'no'),
'outstanding_amount' => array('name' => 'OUTSTANDINGAMT', 'required' => 'no'),
'auto_bill_out' => array('name' => 'AUTOBILLOUTAMT', 'required' => 'no'),
'max_failed_payments' => array('name' => 'MAXFAILEDPAYMENTS', 'required' => 'no'),
'profile_start_date' => array('name' => 'PROFILESTARTDATE' , 'required' => 'no'),
'ship_to_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'ship_to_street' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'ship_to_street_2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'ship_to_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'ship_to_province' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'ship_to_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'ship_to_country' => array('name' => 'SHIPTOCOUNTRY', 'required' => 'no'),
'ship_to_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no'),
'billing_period' => array('name' => 'BILLINGPERIOD', 'required' => 'yes'),
'billing_frequency' => array('name' => 'BILLINGFREQUENCY', 'required' => 'yes'),
'total_billing_cycles' => array('name' => 'TOTALBILLINGCYCLES', 'required' => 'no'),
'trial_billing_period' => array('name' => 'TRIALBILLINGPERIOD', 'required' => 'no'),
'trial_billing_frequnecy' => array('name' => 'TRIALBILLINGFREQUENCY', 'required' => 'no'),
'trial_total_cycles' => array('name' => 'TRIALTOTALBILLINGCYCLES', 'required' => 'no'),
'trial_amount' => array('name' => 'TRIALAMT', 'required' => 'no'),
'currency' => array('name' => 'CURRENCYCODE', 'required' => 'yes'),
'shipping_amount' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'tax_amount' => array('name' => 'TAXAMT', 'required' => 'no'),
'credit_card_type' => array('name' => 'CREDITCARDTYPE', 'required' => 'no'),
'credit_card_number' => array('name' => 'ACCT', 'required' => 'no'),
'expiration_date' => array('name' => 'EXPDATE', 'required' => 'no'),
'cvv2' => array('name' => 'CVV2', 'required' => 'no'),
'start_date' => array('name' => 'STARTDATE', 'required' => 'no'),
'email' => array('name' => 'EMAIL', 'required' => 'no'),
'first_name' => array('name' => 'FIRSTNAME', 'required' => 'no'),
'last_name' => array('name' => 'LASTNAME', 'required' => 'no'),
'street' => array('name' => 'STREET', 'required' => 'yes'),
'street2' => array('name' => 'STREET2', 'required' => 'no'),
'city' => array('name' => 'CITY', 'required' => 'yes'),
'province' => array('name' => 'STATE', 'required' => 'yes'),
'country_code' => array('name' => 'COUNTRYCODE', 'required' => 'yes'),
'postal_code' => array('name' => 'ZIP', 'required' => 'yes'),
'phone_number' => array('name' => 'PHONENUM', 'required' => 'no')
),
'GetRecurringPaymentsProfileDetails' => array(
'profile_id' => array('name' => 'PROFILEID', 'required' => 'yes')
),
'ManageRecurringPaymentsProfileStatus' => array(
'profile_id' => array('name' => 'PROFILEID', 'required' => 'yes'),
'action' => array('name' => 'ACTION', 'required' => 'yes'),
'note' => array('name' => 'NOTE', 'required' => 'no')
),
'DoReferenceTransaction' => array(
'reference_id' => array('name' => 'REFERENCEID', 'required' => 'yes'),
'payment_type' => array('name' => 'PAYMENTACTION', 'required' => 'yes'),
'return_fmf_details' => array('name' => 'RETURNFMFDETAILS', 'required' => 'no'),
'soft_descriptor' => array('name' => 'SOFTDESCRIPTOR', 'required' => 'no'),
'ship_to_name' => array('name' => 'SHIPTONAME', 'required' => 'no'),
'ship_to_street' => array('name' => 'SHIPTOSTREET', 'required' => 'no'),
'ship_to_street_2' => array('name' => 'SHIPTOSTREET2', 'required' => 'no'),
'ship_to_city' => array('name' => 'SHIPTOCITY', 'required' => 'no'),
'ship_to_province' => array('name' => 'SHIPTOSTATE', 'required' => 'no'),
'ship_to_postal_code' => array('name' => 'SHIPTOZIP', 'required' => 'no'),
'ship_to_country' => array('name' => 'SHIPTOCOUNTRY', 'required' => 'no'),
'ship_to_phone_number' => array('name' => 'SHIPTOPHONENUM', 'required' => 'no'),
'billing_period' => array('name' => 'BILLINGPERIOD', 'required' => 'yes'),
'billing_frequency' => array('name' => 'BILLINGFREQUENCY', 'required' => 'yes'),
'phone_number' => array('name' => 'PHONENUM', 'required' => 'no'),
'amount' => array('name' => 'AMT', 'required' => 'yes'),
'currency_code' => array('name' => 'CURRENCYCODE', 'required' => 'no'),
'amount_items' => array('name' => 'ITEMAMT', 'required' => 'no'),
'amount_shipping' => array('name' => 'SHIPPINGAMT', 'required' => 'no'),
'amount_handling' => array('name' => 'HANDLINGAMT', 'required' => 'no'),
'amount_tax' => array('name' => 'TAXAMT', 'required' => 'no'),
'description' => array('name' => 'DESC', 'required' => 'no'),
'custom' => array('name' => 'CUSTOM', 'required' => 'no'),
'invoice_number' => array('name' => 'INVNUM', 'required' => 'no'),
'button_source' => array('name' => 'BUTTONSOURCE', 'required' => 'no'),
'notify_url' => array('name' => 'NOTIFYURL', 'required' => 'no'),
'credit_card_type' => array('name' => 'CREDITCARDTYPE', 'required' => 'no'),
'credit_card_number' => array('name' => 'ACCT', 'required' => 'no'),
'cvv2_code' => array('name' => 'CVV2', 'required' => 'yes'),
'expire_date' => array('name' => 'EXPDATE', 'required' => 'no'),
'start_date' => array('name' => 'STARTDATE', 'required' => 'no'), // For Maestro/Solo cards
'issue_number' => array('name' => 'ISSUENUMBER', 'required' => 'no'), // For maestro/Solo Cards
'email' => array('name' => 'EMAIL', 'required' => 'no'),
'first_name' => array('name' => 'FIRSTNAME', 'required' => 'no'),
'last_name' => array('name' => 'LASTNAME', 'required' => 'no'),
'address1' => array('name' => 'STREET', 'required' => 'no'),
'address2' => array('name' => 'STREET2', 'required' => 'no'),
'city' => array('name' => 'CITY', 'required' => 'no'),
'state' => array('name' => 'STATE', 'required' => 'no'),
'country_code' => array('name' => 'COUNTRYCODE', 'required' => 'no'),
'postal_code' => array('name' => 'ZIP', 'required' => 'no')
)
);
public $ResponseFieldsArray = array(
'DoCapture' => array(
'authorization_id' => 'AUTHORIZATIONID',
'email' => 'EMAIL',
'payer_id' => 'PAYERID',
'payer_status' => 'PAYERSTATUS',
'country_code' => 'COUNTRYCODE',
'business' => 'BUSINESS',
'address_status' => 'ADDRESSSTATUS',
'shipping_name' => 'SHIPTONAME',
'shipping_address1' => 'SHIPTOSTREET',
'shipping_address2' => 'SHIPTOSTREET2',
'shipping_city' => 'SHIPTOCITY',
'shipping_state' => 'SHIPTOSTATE',
'shipping_postal_code' => 'SHIPTOZIP',
'shipping_country_code' => 'SHIPTOCOUNTRYCODE',
'salutation' => 'SALUTATION',
'first_name' => 'FIRSTNAME',
'middle_name' => 'MIDDLENAME',
'last_name' => 'LASTNAME',
'suffix' => 'SUFFIX'
),
'DoAuthorization' => array(
'transaction_id' => 'TRANSACTIONID',
'amount' => 'AMT'
),
'DoReauthorization' => array(
'authorization_id' => 'AUTHORIZATIONID'
),
'DoVoid' => array(
'authorization_id' => 'AUTHORIZATIONID'
),
'DoDirectPayment' => array(
'timestamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'avs_code' => 'AVSCODE',
'cvv2_match' => 'CVV2MATCH',
'transaction_id' => 'TRANSACTIONID',
'amount_total' => 'AMT',
'currency_code' => 'CURRENCYCODE'
)
,
'SetExpressCheckout' => array(
'timestamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'token' => 'TOKEN'
)
,
'DoExpressCheckoutPayment' => array(
'timestamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'token' => 'TOKEN',
'transaction_id' => 'TRANSACTIONID',
'transaction_type' => 'TRANSACTIONTYPE',
'payment_type' => 'PAYMENTTYPE',
'order_time' => 'ORDERTIME',
'amount_total' => 'AMT',
'currency_code' => 'CURRENCYCODE',
'amount_fee' => 'FEEAMT',
'amount_settle' => 'SETTLEAMT',
'amount_tax' => 'TAXAMT',
'exchange_rate' => 'EXCHANGERATE',
'payment_status' => 'PAYMENTSTATUS',
'payment_pending_reason'=> 'PENDINGREASON',
'payment_reason_code' => 'REASONCODE'
)
,
'GetExpressCheckoutDetails' => array(
'timestamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'token' => 'TOKEN',
'email' => 'EMAIL',
'payer_id' => 'PAYERID',
'payer_status' => 'PAYERSTATUS',
'salutation' => 'SALUTATION',
'first_name' => 'FIRSTNAME',
'middle_name' => 'MIDDLENAME',
'last_name' => 'LASTNAME',
'suffix' => 'SUFFIX',
'country_code' => 'COUNTRYCODE',
'business' => 'BUSINESS',
'shipping_name' => 'SHIPTONAME',
'shipping_address1' => 'SHIPTOSTREET',
'shipping_address2' => 'SHIPTOSTREET2',
'shipping_city' => 'SHIPTOCITY',
'shipping_state' => 'SHIPTOSTATE',
'shipping_country_code' => 'SHIPTOCOUNTRYCODE',
'shipping_country_name' => 'SHIPTOCOUNTRYNAME',
'shipping_postal_code' => 'SHIPTOZIP',
'address_id' => 'ADDRESSID', // Is this a returned variable? Some docs say yes, some no
'address_status' => 'ADDRESSSTATUS',
'description' => 'DESC',
'custom' => 'CUSTOM',
'phone_number' => 'PHONENUM'
)
,
'GetTransactionDetails' => array(
'timestamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'receiver_business' => 'RECEIVERBUSINESS',
'receiver_email' => 'RECEIVEREMAIL',
'receiver_id' => 'RECEIVERID',
'email' => 'EMAIL',
'payer_id' => 'PAYERID',
'payer_status' => 'PAYERSTATUS',
'salutation' => 'SALUTATION',
'first_name' => 'FIRSTNAME',
'last_name' => 'LASTNAME',
'middle_name' => 'MIDDLENAME',
'suffix' => 'SUFFIX',
'payer_business' => 'PAYERBUSINESS',
'country_code' => 'COUNTRYCODE',
'business' => 'BUSINESS',
'shipping_name' => 'SHIPTONAME',
'shipping_address1' => 'SHIPTOSTREET',
'shipping_address2' => 'SHIPTOSTREET2',
'shipping_city' => 'SHIPTOCITY',
'shipping_state' => 'SHIPTOSTATE',
'shipping_country_code' => 'SHIPTOCOUNTRYCODE',
'shipping_country_name' => 'SHIPTOCOUNTRYNAME',
'shipping_postal_code' => 'SHIPTOZIP',
'address_id' => 'ADDRESSID', // Is this a returned variable? Some docs say yes, some no
'address_status' => 'ADDRESSSTATUS',
'address_owner' => 'ADDRESSOWNER',
'parent_transaction_id' => 'PARENTTRANSACTIONID',
'transaction_id' => 'TRANSACTIONID',
'receipt_id' => 'RECEIPTID',
'transaction_type' => 'TRANSACTIONTYPE',
'payment_type' => 'PAYMENTTYPE',
'order_time' => 'ORDERTIME',
'amount_total' => 'AMT',
'currency_code' => 'CURRENCYCODE',
'amount_fee' => 'FEEAMT',
'amount_settle' => 'SETTLEAMT',
'amount_tax' => 'TAXAMT',
'exchange_rate' => 'EXCHANGERATE',
'payment_status' => 'PAYMENTSTATUS',
'payment_pending_reason' => 'PENDINGREASON',
'payment_reason_code' => 'REASONCODE',
'amount_sales_tax' => 'SALESTAX',
'invoice_number' => 'INVNUM',
'note' => 'NOTE',
'custom' => 'CUSTOM',
'subscription_id' => 'SUBSCRIPTIONID',
'subscription_date' => 'SUBSCRIPTIONDATE',
'effective_date' => 'EFFECTIVEDATE',
'retry_time' => 'RETRYTIME',
'user_name' => 'USERNAME',
'recurrences' => 'RECURRENCES',
'reattempt' => 'REATTEMPT',
'recurring' => 'RECURRING',
'period' => 'PERIOD',
'buyer_id' => 'BUYERID',
'closing_date' => 'CLOSINGDATE',
'multi_item' => 'MULTIITEM'
)
,
'RefundTransaction' => array(
'refund_transaction_id' => 'REFUNDTRANSACTIONID',
'amount_refund_net' => 'NETFUNDAMT',
'amount_refund_fee' => 'FEEREFUNDAMT',
'amount_refund_total' => 'GROSSREFUNDAMT'
),
'CreateRecurringPaymentsProfile' => array(
'profile_id' => 'PROFILEID',
'status' => 'STATUS'
),
'UpdateRecurringPaymentsProfile' => array(
'profile_id' => 'PROFILEID',
),
'GetRecurringPaymentsProfileDetails' => array(
'profile_id' => 'PROFILEID',
'status' => 'STATUS',
'auto_bill_out' => 'AUTOBILLOUTAMT',
'description' => 'DESC',
'max_failed_payments' => 'MAXFAILEDPAYMENTS',
'subcriber_name' => 'SUBSCRIBERNAME',
'profile_start_date' => 'PROFILESTARTDATE',
'next_billing_date' => 'NEXTBILLINGDATE',
'num_cycles_completed' => 'NUMCYCLESCOMPLETED',
'num_cycles_remaining' => 'NUMCYCLESREMAINING',
'outstanding_balance' => 'OUTSTANDINGBALANCE',
'failed_billing_account'=> 'FAILEDPAYMENTCOUNT',
'trial_amount_paid' => 'TRIALAMTPAID',
'regular_amount_paid' => 'REGULARAMTPAID',
'aggregate_amount' => 'AGGREGATEAMT',
'aggregate_option_amount' => 'AGGREGATEOPTIONALAMT',
'final_payment_due_date' => 'FINALPAYMENTDUEDATE',
'time_stamp' => 'TIMESTAMP',
'correlation_id' => 'CORRELATIONID',
'ack' => 'ACK',
'version' => 'VERSION',
'build' => 'BUILD',
'ship_to_street' => 'SHIPTOSTREET',
'ship_to_street2' => 'SHIPTOSTREET2',
'ship_to_city' => 'SHIPTOCITY',
'ship_to_province' => 'SHIPTOSTATE',
'ship_to_postalcode' => 'SHIPTOZIP',
'ship_to_country_code' => 'SHIPTOCOUNTRYCODE',
'ship_to_country' => 'SHIPTOCOUNTRY',
'ship_to_country_name' => 'SHIPTOCOUNTRYNAME',
'ship_address_owner' => 'SHIPADDRESSOWNER',
'ship_address_status' => 'SHIPADDRESSSTATUS',
'billing_period' => 'BILLINGPERIOD',
'billing_frequency' => 'BILLINGFREQUENCY',
'total_biling_cycles' => 'TOTALBILLINGCYCLES',
'currency' => 'CURRENCYCODE',
'amount' => 'AMT',
'shipping_amount' => 'SHIPPINGAMT',
'tax_amount' => 'TAXAMT',
'regualar_billing_period' => 'REGULARBILLINGPERIOD',
'regular_billing_frequency' => 'REGULARBILLINGFREQUENCY',
'regular_billing_cycles' => 'REGULARTOTALBILLINGCYCLES',
'regular_currency' => 'REGULARCURRENCYCODE',
'regular_amount' => 'REGULARAMT',
'regular_shipping_amount' => 'REGULARSHIPPINGAMT',
'regular_tax_amount' => 'REGULARTAXAMT',
'credit_card_num' => 'ACCT',
'credit_card_type' => 'CREDITCARDTYPE',
'expiration_date' => 'EXPDATE',
'email' => 'EMAIL',
'first_name' => 'FIRSTNAME',
'last_name' => 'LASTNAME',
'street' => 'STREET',
'street2' => 'STREET2',
'city' => 'CITY',
'state' => 'STATE',
'postal_code' => 'ZIP',
'country_code' => 'COUNTRYCODE',
'country' => 'COUNTRY',
'address_owner' => 'ADDRESSOWNER',
'address_status' => 'ADDRESSSTATUS',
'payer_status' => 'PAYERSTATUS'
),
'ManageRecurringPaymentsProfileStatus' => array(
'profile_id' => 'PROFILEID',
),
'DoReferenceTransaction' => array(
'avs_code' => 'AVSCODE',
'cvv2_match' => 'CVV2MATCH',
'billing_agreement_id' => 'BILLINGAGREEMENTID', // Should include filter IDs, but this will have to be done in the function level
'transaction_id' => 'TRANSACTIONID',
'transaction_type' => 'TRANSACTIONTYPE',
'payment_type' => 'PAYMENTTYPE',
'order_time' => 'ORDERTIME',
'amount_total' => 'AMT',
'currency_code' => 'CURRENCYCODE',
'ammount_fee' => 'FEEAMT',
'amount_settle' => 'SETTLEAMT',
'amount_tax' => 'TAXAMT',
'exchange_rate' => 'EXCHANGERATE',
'payment_status' => 'PAYMENTSTATUS',
'pending_reason' => 'PENDINGREASON',
'reason_code' => 'REASONCODE',
'protection_eligibility'=> 'PROTECTIONELIGIBILITY',
'ebay_item_auction_transaction_id' => 'EBAYITEMAUCTIONTXNID',
'payment_error' => 'PAYMENTERROR'
)
);
// CONSTRUCT
function __construct($config, $sandbox = false)
{
// Determine our API endpoint
if ($sandbox)
{
$this->API_ENDPOINT = 'https://api-3t.sandbox.paypal.com/nvp';
$this->PAYPAL_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
}
else
{
$this->API_ENDPOINT = 'https://api-3t.paypal.com/nvp';
$this->PAYPAL_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
}
$this->API_USERNAME = (is_array ($config) && isset ($config['api_username'])) ? $config['api_username'] : '';
$this->API_PASSWORD = (is_array ($config) && isset ($config['api_password'])) ? $config['api_password'] : '';
$this->API_SIGNATURE = (is_array ($config) && isset ($config['api_signature'])) ? $config['api_signature'] : '';
$this->USE_PROXY = (is_array ($config) && isset ($config['use_proxy'])) ? $config['use_proxy'] : '';
$this->PROXY_HOST = (is_array ($config) && isset ($config['proxy_host'])) ? $config['proxy_host'] : '';
$this->PROXY_PORT = (is_array ($config) && isset ($config['proxy_port'])) ? $config['proxy_port'] : '';
$this->return_url = (is_array ($config) && isset ($config['return_url'])) ? $config['return_url'] : '';
$this->cancel_url = (is_array ($config) && isset ($config['cancel_url'])) ? $config['cancel_url'] : '';
}
public function do_capture()
{
// urlencode the needed variables
$this->urlencodeVariables();
/* Construct the request string that will be sent to PayPal.
The variable $nvpstr contains all the variables and is a
name value pair string with & as a delimiter */
$nvpstr = $this->generateNVPString('DoCapture');
// decode the variables incase we still require access to them in our program
$this->urldecodeVariables();
/* Make the API call to PayPal, using API signature.
The API response is stored in an associative array called $this->Response */
$this->Response = $this->hash_call("DoCapture", $nvpstr);
// Format our response and return the outcome
return $this->format_response('DoCapture');
}
public function do_authorization()
{
// urlencode the needed variables
$this->urlencodeVariables();
/* Construct the request string that will be sent to PayPal.
The variable $nvpstr contains all the variables and is a
name value pair string with & as a delimiter */
$nvpstr = $this->generateNVPString('DoAuthorization');
// decode the variables incase we still require access to them in our program
$this->urldecodeVariables();
/* Make the API call to PayPal, using API signature.
The API response is stored in an associative array called $this->Response */
$this->Response = $this->hash_call("DoAuthorization", $nvpstr);
// Format our response and return the outcome
return $this->format_response('DoAuthorization');
}