/** * Store a newly created resource in storage. * * @return Response */ public function store() { Log::debug('IPN receiver - $_POST array: ' . print_r($_POST, TRUE)); $ipnOrder = IPN::getOrder(); Log::debug('IPN receiver - After processing... IPN order: ' . print_r($ipnOrder, TRUE)); $orderItem = $ipnOrder->items->first(); $order = Order::find((int) $orderItem->item_number); $order->paypal_txn_id = $ipnOrder->txn_id; $order->paypal_fee = $ipnOrder->mc_fee; $order->ipn_order_id = $ipnOrder->id; //$order->id = (int) $orderItem->item_number; if ($ipnOrder->memo) { $order->order_notes .= "\n\n" . $ipnOrder->memo; } if ($order->delivery_terms == 'mp3_only') { $order->order_status = 'Completed'; } else { $order->order_status = 'Payment Received'; } $order->save(); // After the order is persisted to IPN tables, // we send e-mail notification to customer. // This ensures that e-mail confirmation is sent, // if customer does NOT return to our site. $result = OrdersController::sendEmailConfirmationExternal($order); }
public function action_complete() { // Get the transaction details. $fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send(); $data = $fetch->getData(); // Add the buyer email to parameters. $parameters = $this->_payment_vars() + array('email' => $data['EMAIL']); /** @var Payment_PayPal_CreateRecurringPaymentsRequest $request */ $request = $this->_gateway->createRecurringPaymentsProfile($parameters); // Overwrite Item Category. $data = $request->getData(); $data['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = $this->_config['itemCategory']; /** @var Omnipay\PayPal\Message\ExpressAuthorizeResponse $response */ $response = $request->sendData($data); if ($response->isSuccessful()) { $response_data = $response->getData(); // Get the transaction details. // $fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send(); // $data = $fetch->getData(); ORM::factory('Payment_Subscription')->values(array('user_id' => $this->user->id, 'package_id' => $this->_package->id, 'status' => Model_Payment_Subscription::PENDING, 'recurring_payment_id' => $response_data['PROFILEID']))->create(); Hint::success(Kohana::message('payment', 'payment.success')); $this->redirect(Route::get('payment')->uri()); } else { // Log the error. Kohana::$log->add(Log::ERROR, IPN::array_to_string($response->getData())); throw HTTP_Exception::factory('403', 'Something went wrong, no cash should have been drawn, if the error proceeds contact support!'); } }
function __construct($err) { $this->errorlog = $err; parent::__construct(); $this->showRecaptcha(null, null, true); }
/** * Create a transaction for the payment. */ protected function _create_transaction() { ORM::factory('Payment_Transaction')->values(array('user_id' => $this->_subscription->user_id, 'package_id' => $this->_subscription->package_id, 'token' => $this->_IPN->get_data('recurring_payment_id'), 'status' => Model_Payment_Transaction::STATUS_COMPLETED, 'email' => $this->_IPN->get_data('payer_email'), 'first_name' => $this->_IPN->get_data('first_name'), 'last_name' => $this->_IPN->get_data('last_name'), 'country' => $this->_IPN->get_data('residence_country')))->create(); }
function eme_paypal_notification() { require_once 'payment_gateways/paypal/IPN.php'; $ipn = new IPN(); // the paypal url, or the sandbox url, or the ipn test url //$ipn->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; $ipn->paypal_url = get_option('eme_paypal_url'); // your paypal email (the one that receives the payments) $ipn->paypal_email = get_option('eme_paypal_business'); // log to file options $ipn->log_to_file = false; // write logs to file $ipn->log_filename = '/path/to/ipn.log'; // the log filename (should NOT be web accessible and should be writable) // log to e-mail options $ipn->log_to_email = false; // send logs by e-mail $ipn->log_email = ''; // where you want to receive the logs $ipn->log_subject = 'IPN Log: '; // prefix for the e-mail subject // database information $ipn->log_to_db = false; // false not recommended $ipn->db_host = 'localhost'; // database host $ipn->db_user = ''; // database user $ipn->db_pass = ''; // database password $ipn->db_name = ''; // database name // array of currencies accepted or false to disable //$ipn->currencies = array('USD','EUR'); $ipn->currencies = false; // date format on log headers (default: dd/mm/YYYY HH:mm:ss) // see http://php.net/date $ipn->date_format = 'd/m/Y H:i:s'; // Prefix for file and mail logs $ipn->pretty_ipn = "IPN Values received:\n\n"; // configuration ended, do the actual check if ($ipn->ipn_is_valid()) { /* A valid ipn was received and passed preliminary validations You can now do any custom validations you wish to ensure the payment was correct You can access the IPN data with $ipn->ipn['value'] The complete() method below logs the valid IPN to the places you choose */ $payment_id = intval($ipn->ipn['item_number']); eme_update_payment_payed($payment_id); $ipn->complete(); } }
// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ /** * page that accepts IPN transaction information from the paypal servers. A link to * this page needs to be associated with your paypal business account. * * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net> * @copyright Vincent Furia 2005 - 2006 * @package paypal */ /** * Require geeklog */ require_once '../lib-common.php'; /** * Get needed paypal classes */ require_once $_CONF['path'] . 'plugins/paypal/classes/IPN.class.php'; // Process IPN request $ipn = new IPN(); $ipn->Process($_POST); // Finished (this isn't necessary...but heck...why not?) echo "Thanks";
/** * Return the user from paypal, and process the payment. * * @throws HTTP_Exception */ public function action_complete() { /** @var Omnipay\PayPal\Message\ExpressAuthorizeResponse $response */ $response = $this->_gateway->completePurchase($this->_payment_vars())->send(); if ($response->isSuccessful()) { // Get the transaction details. $fetch = $this->_gateway->fetchTransaction($this->_payment_vars())->send(); $data = $fetch->getData(); $transaction = ORM::factory('Payment_Transaction')->where('TOKEN', '=', $data['TOKEN'])->find(); // Update the transaction with the buyers information. $transaction->values(array('status' => 'completed', 'email' => $data['EMAIL'], 'first_name' => $data['FIRSTNAME'], 'last_name' => $data['LASTNAME'], 'country' => $data['COUNTRYCODE']))->save(); // Give the player the rewards. foreach ($this->_package->rewards as $key => $value) { $reward = Payment_Reward::factory($key, $value); $reward->reward($this->user); } $this->user->save(); Hint::success(Kohana::message('payment', 'payment.success')); $this->redirect(Route::get('payment')->uri()); } else { // Log the error. Kohana::$log->add(Log::ERROR, IPN::array_to_string($response->getData())); throw HTTP_Exception::factory('403', 'Something went wrong, no cash should have been drawn, if the error proceeds contact support!'); } }