/[drupal]/contributions/modules/lm_paypal/lm_paypal.install
ViewVC logotype

Contents of /contributions/modules/lm_paypal/lm_paypal.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.26 - (show annotations) (download) (as text)
Thu Jun 14 00:31:53 2007 UTC (2 years, 5 months ago) by leemcl
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, DRUPAL-4-7--1-0, DRUPAL-4-7--1-1, HEAD
Branch point for: DRUPAL-5, DRUPAL-4-7, DRUPAL-6--1
Changes since 1.25: +11 -3 lines
File MIME type: text/x-php
verify_sign too short, made longer
payer_status from PayPal appears to now be a string, changed
1 <?php
2
3 // $Id: lm_paypal.install,v 1.25 2006/10/25 15:10:50 leemcl Exp $
4
5 /**
6 * @file
7 *
8 * Install or update the PayPal interface.
9 *
10 * Lee McLoughlin <lee@lmmrtech.com>. July 2006
11 *
12 * These database fields are from:
13 * https://www.paypal.com/en_US/pdf/PP_OrderManagement_IntegrationGuide.pdf
14 * See also:
15 * https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html
16 * https://www.paypal.com/uk/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside
17 */
18
19 // TODO: Once I've been running lm_paypal for a while work out which
20 // ipn fields are unnecessary and remove them.
21
22 function lm_paypal_install() {
23 $mysql_create_ipns = "
24 CREATE TABLE {lm_paypal_ipns} (
25 id mediumint not null auto_increment, # My ID for received IPNs
26 timestamp int(11) unsigned not null, # unix time when ipn arrived
27
28 txn_id varchar(20) not null default '', # Paypal generated transaction id
29 processed int(1) default '0', # set if processed
30
31 test_ipn int(1) default null, # Only set by sandbox to 1
32 verify_sign varchar(120) default null, # Security string (Was 20)
33
34 # Website Payments Standard, Website Payments Pro, and Refund Information
35 # SOME FIELDS OMITTED
36
37 parent_txn_id varchar(20) default null, # In the case of a refund, reversal, or canceled reversal, this variable contains the txn_id of the original transaction, while txn_id contains a new ID for the new transaction.
38 payment_date varchar(28) default null, # Time/Date stamp generated by PayPal , in the following format: HH:MM:SS DD Mmm YY, YYYY PST
39 payment_status varchar(20) default null, # Canceled_Reversal,Completed,Denied,Expired,Failed,In-Progress,Partially-Refunded,Pending,Processed,Refunded,Reversed,Voided
40 payment_type varchar(20) default null, # echeck,instant
41 pending_reason varchar(20) default null, # address,authorization,echeck,intl,multicurrency,unilateral,upgrade,verify,other
42 reason_code varchar(20) default null, # chargeback,guarantee,buyer-complaint,refund,other
43
44 # Buyer Information
45
46 payer_email varchar(127) default null, # Customers primary email address. Use this email to provide any credits.
47 first_name varchar(64) default null, # Customers first name
48 last_name varchar(64) default null, # Customers last name
49 payer_business_name varchar(127) default null, # Customers company name, if customer represents a business
50 address_name varchar(128) default null, # Name used with address (included when the customer provides a Gift Address)
51 address_street varchar(200) default null, # Customers street address
52 address_city varchar(40) default null, # City of customers address
53 address_zip varchar(20) default null, # Zip code of customers address.
54 address_country varchar(64) default null, # Country of customers address.
55 address_country_code varchar(2) default null, # Two-character ISO 3166 country code
56 address_state varchar(40) default null, # State of customers address
57 address_status int(1) default null, # Customer provided a confirmed/unconfirmed address.
58 payer_id varchar(13) default null, # Unique customer ID.
59 payer_status varchar(40) default null, # Customer has a Verified|Unverified PayPal account.
60 residence_country varchar(2) default null, # Two-character ISO 3166 country code
61
62 # Business Information
63
64 business varchar(127) default null, # Email address or account ID of the payment recipient (that is, the merchant). Equivalent to the values of receiver_email (if payment is sent to primary account) and business set in the Website Payment HTML. NOTE: The value of this variable is normalized to lowercase characters.
65 item_name varchar(127) default null, # Item name as passed by you, the merchant. Or, if not passed by you, as entered by your customer. If this is a shopping cart transaction, PayPal will append the number of the item (e.g., item_name1, item_name2).
66 quantity int unsigned not null default '0',
67 shipping decimal(10,2) default null,
68 item_number varchar(127) default null, # Pass-through variable for you to track purchases. It will get passed back to you at the completion of the payment. If omitted, no variable will be passed back to you.
69 receiver_email varchar(127) default null, # Primary email address of the payment recipient (that is, the merchant). If the payment is sent to a non-primary email address on your PayPal account, the receiver_email is still your primary email. NOTE: The value of this variable is normalized to lowercase characters.
70 receiver_id varchar(13) default null, # Unique account ID of the payment recipient (i.e., the merchant). This is the same as the recipient's referral ID.
71
72 # Advanced and Custom Information
73
74 custom varchar(255) default null, # Custom value as passed by you, the merchant. These are passthrough variables that are never presented to your customer
75 invoice varchar(127) default null, # Passthrough variable you can use to identify your Invoice Number for this purchase. If omittted, no variable is passed back.
76 memo varchar(255) default null, # Memo as entered by your customer in PayPal Website Payments note field.
77 option_name1 varchar(64) default null, # Option 1 name as requested by you.
78 option_name2 varchar(64) default null, # Option 2 name as requested by you.
79 option_selection1 varchar(200) default null, # Option 1 choice as entered by your customer.
80 option_selection2 varchar(200) default null, # Option 2 choice as entered by your customer.
81 tax varchar(20) default null, # Amount of tax charged on payment.
82
83 # SOME FIELDS OMITTED
84
85 mc_currency varchar(3) default null, # Three character currency code
86 # SOME FIELDS OMITTED
87 payment_fee decimal(10,2) default null, # USD transaction fee associated with the payment. payment_gross minus payment_fee equals the amount deposited into the receiver email account. Is empty for non-USD payments. If this amount is negative, it signifies a refund or reversal, and either of those payment statuses can be for the full or partial amount of the original transaction fee. NOTE: This is a deprecated field. Use mc_fee instead.
88 payment_gross decimal(10,2) default null, # Full USD amount of the customer's payment, before transaction fee is subtracted. Will be empty for non-USD payments. This is a legacy field replaced by mc_gross. If this amount is negative, it signifies a refund or reversal, and either of those payment statuses can be for the full or partial amount of the original transaction.
89 mc_fee decimal(10,2) default null, # Transaction fee associated with the payment. mc_gross minus mc_fee equals the amount deposited into the receiver_email account. Equivalent to payment_fee for USD payments. If this amount is negative, it signifies a refund or reversal, and either of those payment statuses can be for the full or partial amount of the original transaction fee.
90 mc_gross decimal(10,2) default null, # Full amount of the customer's payment, before transaction fee is subtracted. Equivalent to payment_gross for USD payments. If this amount is negative, it signifies a refund or reversal, and either of those payment statuses can be for the full or partial amount of the original transaction.
91 settle_amount decimal(10,2) default null, # Amount that is deposited into the accounts primary balance after a currency conversion from automatic conversion (through your Payment Receiving Preferences) or manual conversion (through manually accepting a payment).
92 settle_currency varchar(3) default null, # Three character currency code.
93 exchange_rate decimal(12,6) default null, # Exchange rate used if a currency conversion occurred.
94
95 # Auctions - NOT SUPPORTED
96
97 # Mass Payment - NOT SUPPORTED
98
99 # Subscriptions Variables
100
101 txn_type varchar(20) default null, # subscr_signup, subscr_cancel, subscr_failed, subscr_payment, subscr_eot, subscr_modify
102 subscr_date varchar(28) default null, # Start date or cancellation date depending
103 subscr_effective varchar(28) default null, # Date when the subscription modification will be effective
104
105 period1 varchar(20) default null, # Trial subscription interval in days, weeks, months, years (example: a 4 day interval is period1: 4 D).
106 period2 varchar(20) default null, # Trial subscription interval in days, weeks, months, or years.
107 period3 varchar(20) default null, # Regular subscription interval in days, weeks, months, or years.
108 amount1 decimal(10,2) default null, # Amount of payment for trial period 1 for USD payments; otherwise blank (optional).
109 amount2 decimal(10,2) default null, # A mount of payment for trial period 2 for USD payments; otherwise blank (optional).
110 amount3 decimal(10,2) default null, # Amount of payment for regular subscription period for USD payments; otherwise blank.
111 mc_amount1 decimal(10,2) default null, # Amount of payment for trial period 1, regardless of currency (optional).
112 mc_amount2 decimal(10,2) default null, # Amount of payment for trial period 2, regardless of currency (optional).
113 mc_amount3 decimal(10,2) default null, # Amount of payment for regular subscription period, regardless of currency.
114 recurring int(1) default null, # Indicates whether regular rate recurs (1 is yes, blank is no).
115 reattempt int(1) default null, # Indicates whether reattempts should occur upon payment failures (1 is yes, blank is no).
116 retry_at varchar(28) default null, # Date PayPal will retry a failed subscription payment.
117 recur_times int default null, # The number of payment installments that will occur at the regular rate.
118 subscr_id varchar(20) default null, # ID generated by PayPal for the subscriber.
119
120 KEY txn_id (txn_id),
121 PRIMARY KEY(id)
122 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
123
124 $ret = '';
125 switch ($GLOBALS['db_type']) {
126 case 'mysql':
127 $ret .= lm_paypal_create_table('lm_paypal_ipns', $mysql_create_ipns);
128 break;
129
130 case 'mysqli': // Bad Lee... using mysql_insert_id in lm_paypal!
131 case 'pgsql':
132 watchdog('lm_paypal', t('%db_type not supported yet', array('%db_type' => $GLOBALS['db_type'])), WATCHDOG_ERROR);
133 return;
134 break;
135 }
136 if ($ret == '') {
137 $msg = t('lm_paypal created tables');
138 }
139 else {
140 $msg = t('lm_paypal FAILED to create tables:') . $ret;
141 }
142 drupal_set_message($msg);
143 }
144
145 function lm_paypal_create_table($table, $sql) {
146 $res = db_query($sql);
147 if (!$res) {
148 $ret = t('Failed to create table:') . $table . t('. ');
149 watchdog('lm_paypal', $ret, WATCHDOG_ERROR);
150 return $ret;
151 }
152 return '';
153 }
154
155 function lm_paypal_update_1() {
156 $items = array();
157 $items[] = update_sql("ALTER TABLE {lm_paypal_ipns} CHANGE verify_sign verify_sign varchar(120) default null");
158 $items[] = update_sql("ALTER TABLE {lm_paypal_ipns} CHANGE payer_status payer_status varchar(40) default null");
159 return $items;
160 }
161
162
163 /*
164 * Example from: http://drupal.org/node/51220
165 function example_update_1() {
166 $items = array();
167 $items[] = update_sql("ALTER TABLE {example} ADD new_column text");
168 $items[] = update_sql("ALTER TABLE {example} DROP old_column");
169 return $items;
170 }
171 */
172
173 ?>

  ViewVC Help
Powered by ViewVC 1.1.2