- if($status !== 'verified') { # it's really from PayPal
- paypal_ipn_main_debug("status is not \"verified\" but is \"$status\"");
- } elseif ($txn_type !== 'subscr_payment' && $txn_type !== 'web_accept') {
- if ($txn_type !== 'subscr_signup' && $txn_type !== 'subscr_cancel' && $txn_type !== 'subscr_eot') {
- # subscr_cancel is sent when they cancel. After that:
- # subscr_eot is sent when their next payment would have been
- paypal_ipn_main_debug("txn_type is not \"subscr_payment\", \"subscr_signup\", \"subscr_cancel\", \"subscr_eot\" or \"web_accept\" but is \"$txn_type\"");
- }
- } elseif ($payment_status !== 'Completed') { # payment has completed
- if ($payment_status !== 'Pending') {
- paypal_ipn_main_debug("payment_status is not \"Completed\" or \"Pending\", but is \"$payment_status\"");
- }
- } elseif ($receiver_email !== $GLOBALS['paypal_email']) {
- paypal_ipn_main_debug("payment isn't to us ($GLOBALS[paypal_email]) but to \"$receiver_email\"");
- } elseif ($mc_currency !== 'USD') {
- paypal_ipn_main_debug("Currency isn't \"USD\" but is \"$mc_currency\"");
- } else {
- $custom_words = explode(' ', $custom);
- if (!isset($GLOBALS['payment_handlers'][$custom_words[0]])) {
- paypal_ipn_main_debug("\$custom's first word isn't in GLOBALS[payment_handlers]. \$custom: \"$custom\"");
- } else {
- # FIXME add parameter with everything from paypal
- $ret = file_run($GLOBALS['payment_handlers'][$custom_words[0]], $custom_words, $mc_gross, $row);
- if ($ret and is_array($ret) and isset($ret['success']) and $ret['success']) {
- $update = ['processed' => '1'];
- if (isset($ret['for_table_id']) and isset($ret['for_row_id'])) {
- $tid = format_int_0((string)$ret['for_table_id']);
- $rid = format_int_0((string)$ret['for_row_id']);
- if ((int)$tid > 0 and (int)$rid > 0) {
- $update['for_table_id'] = $tid;
- $update['for_row_id'] = $rid;
- }
- }
- db_update_assoc('paypal_ipn', $update);
- } else {
- paypal_ipn_main_debug($user, $old_date, $was_expired);
- }
- }
- }
+ if($status !== 'verified') { # it's really from PayPal
+ paypal_ipn_main_debug("status is not \"verified\" but is \"$status\"");
+ } elseif ($txn_type !== 'subscr_payment' && $txn_type !== 'web_accept') {
+ if ($txn_type !== 'subscr_signup' && $txn_type !== 'subscr_cancel' && $txn_type !== 'subscr_eot') {
+ # subscr_cancel is sent when they cancel. After that:
+ # subscr_eot is sent when their next payment would have been
+ paypal_ipn_main_debug("txn_type is not \"subscr_payment\", \"subscr_signup\", \"subscr_cancel\", \"subscr_eot\" or \"web_accept\" but is \"$txn_type\"");
+ }
+ } elseif ($payment_status !== 'Completed') { # payment has completed
+ if ($payment_status !== 'Pending') {
+ paypal_ipn_main_debug("payment_status is not \"Completed\" or \"Pending\", but is \"$payment_status\"");
+ }
+ } elseif ($receiver_email !== $GLOBALS['paypal_email']) {
+ paypal_ipn_main_debug("payment isn't to us ($GLOBALS[paypal_email]) but to \"$receiver_email\"");
+ } elseif ($mc_currency !== 'USD') {
+ paypal_ipn_main_debug("Currency isn't \"USD\" but is \"$mc_currency\"");
+ } else {
+ $custom_words = explode(' ', $custom);
+ if (!isset($GLOBALS['payment_handlers'][$custom_words[0]])) {
+ paypal_ipn_main_debug("\$custom's first word isn't in GLOBALS[payment_handlers]. \$custom: \"$custom\"");
+ } else {
+ $ret = file_run($GLOBALS['payment_handlers'][$custom_words[0]], $custom_words, $mc_gross, $row);
+ if ($ret and is_array($ret) and isset($ret['success']) and $ret['success']) {
+ $update = ['processed' => '1'];
+ if (isset($ret['for_table_id']) and isset($ret['for_row_id'])) {
+ $tid = format_int_0((string)$ret['for_table_id']);
+ $rid = format_int_0((string)$ret['for_row_id']);
+ if ((int)$tid > 0 and (int)$rid > 0) {
+ $update['for_table_id'] = $tid;
+ $update['for_row_id'] = $rid;
+ }
+ }
+ db_update_assoc('paypal_ipn', $update);
+ } else {
+ paypal_ipn_main_debug($user, $old_date, $was_expired);
+ }
+ }
+ }