function checkAndvalidateIPN() { if ($this->booLogEvents) { ini_set('log_errors', true); ini_set('error_log', $this->strLogfile); } include 'PHP-PayPal-IPN/ipnlistener.php'; $listener = new IpnListener(); $listener->use_sandbox = PAYPAL_SANDBOX; $listener->use_ssl = true; $listener->use_curl = false; if (function_exists('curl_init')) { $listener->use_curl = true; } try { $listener->requirePostMethod(); $verified = $listener->processIpn(); } catch (Exception $e) { error_log($e->getMessage()); exit(0); } if ($this->booLogEvents) { error_log($listener->getTextReport()); } if ($verified) { if ($_POST['payment_status'] != 'Completed') { if ($this->booLogEvents) { error_log('FAIL - payment_status is not Completed'); } return false; } if ($_POST['receiver_email'] != $this->strPaypalAccount) { if ($this->booLogEvents) { error_log('FAIL - receiver_email is: ' . $_POST['receiver_email'] . ' expected: ' . $this->strPaypalAccount); } return false; } if ($_POST['mc_currency'] != PAYPAL_CURRENCY) { if ($this->booLogEvents) { error_log('FAIL - currency is: ' . $_POST['mc_currency'] . ' expected: ' . PAYPAL_CURRENCY); } return false; } // process payment $objPayment = new GSALES2_OBJECT_PAYMENT(); $objPayment->setPaymentProvider('paypal'); $objPayment->setAmount($_POST['mc_gross']); $objPayment->setInvoiceId($_POST['custom']); $objPayment->setTransactionId($_POST['txn_id']); if ($this->booLogEvents) { error_log('Payment object:' . print_r($objPayment, true)); } // set invoice to paid return $objPayment->checkPaidAmountAndSetInvoiceAsPaid(); } else { if ($this->booLogEvents) { error_log('!!! Invalid IPN !!! '); } } }
function checkAndvalidatePN() { $debug = $this->booLogEvents; if ($debug) { $f = fopen($this->strLogfile, 'a+'); } if ($debug) { fwrite($f, 'SOFORTU PAYMENT NOTIFICATION' . "\n"); } if ($debug) { fwrite($f, 'POST' . print_r($_POST, true)); } if ($debug) { fwrite($f, 'GET' . print_r($_GET, true)); } // hash berechnen $data = array('transaction' => $_POST[transaction], 'user_id' => $_POST[user_id], 'project_id' => $_POST[project_id], 'sender_holder' => $_POST[sender_holder], 'sender_account_number' => $_POST[sender_account_number], 'sender_bank_code' => $_POST[sender_bank_code], 'sender_bank_name' => $_POST[sender_bank_name], 'sender_bank_bic' => $_POST[sender_bank_bic], 'sender_iban' => $_POST[sender_iban], 'sender_country_id' => $_POST[sender_country_id], 'recipient_holder' => $_POST[recipient_holder], 'recipient_account_number' => $_POST[recipient_account_number], 'recipient_bank_code' => $_POST[recipient_bank_code], 'recipient_bank_name' => $_POST[recipient_bank_name], 'recipient_bank_bic' => $_POST[recipient_bank_bic], 'recipient_iban' => $_POST[recipient_iban], 'recipient_country_id' => $_POST[recipient_country_id], 'international_transaction' => $_POST[international_transaction], 'amount' => $_POST[amount], 'currency_id' => $_POST[currency_id], 'reason_1' => $_POST[reason_1], 'reason_2' => $_POST[reason_2], 'security_criteria' => $_POST[security_criteria], 'user_variable_0' => $_POST[user_variable_0], 'user_variable_1' => $_POST[user_variable_1], 'user_variable_2' => $_POST[user_variable_2], 'user_variable_3' => $_POST[user_variable_3], 'user_variable_4' => $_POST[user_variable_4], 'user_variable_5' => $_POST[user_variable_5], 'created' => $_POST[created], 'project_password' => $this->strProjectPass); $data_implode = implode('|', $data); $hash = sha1($data_implode); if ($debug) { fwrite($f, 'DATA IMPLODE:' . $data_implode); } if ($debug) { fwrite($f, 'HASH:' . $hash); } if ($hash == $_POST['hash']) { if ($debug) { fwrite($f, 'HASH OKAY' . "\n"); } // process payment $objPayment = new GSALES2_OBJECT_PAYMENT(); $objPayment->setPaymentProvider('sofortu'); $objPayment->setAmount($_POST['amount']); $objPayment->setInvoiceId($_POST['user_variable_0']); $objPayment->setTransactionId($_POST['transaction']); if ($debug) { fwrite($f, 'Payment Object: ' . print_r($objPayment, true) . "\n"); } // set invoice to paid return $objPayment->checkPaidAmountAndSetInvoiceAsPaid(); return true; } else { if ($debug) { fwrite($f, 'HASH NOT OKAY' . "\n"); } return false; } if ($debug) { fclose($f); } }