static function populateForm($form) { $form->configure->email->value(basket::getEmailAddress()); $form->configure->paypal->checked(basket::isPaypal()); $form->configure->paypal_account->value(basket::getPaypalAccount()); $form->configure->currency->selected(basket::getCurrency()); }
static function populateForm($form) { $form->configure->email->value(basket::getEmailAddress()); $form->configure->side_bar->checked(basket::is_side_bar_only()); $form->configure->paypal->checked(basket::isPaypal()); $form->configure->paypal_account->value(basket::getPaypalAccount()); $form->configure->currency->selected(basket::getCurrency()); $form->configure->allow_pickup->checked(basket::isAllowPickup()); $form->configure->order_prefix->value(basket::getOrderPrefix()); }
static function populateForm($form) { $form->configure->webshop->value(basket::getWebshop()); $form->configure->website->value(basket::getWebsite()); $form->configure->email->value(basket::getEmailAddress()); $form->configure->side_bar->checked(basket::is_side_bar_only()); $form->configure->paypal->checked(basket::isPaypal()); $form->configure->paypal_account->value(basket::getPaypalAccount()); $form->configure->currency->selected(basket::getCurrency()); $form->configure->allow_pickup->checked(basket::isAllowPickup()); $form->configure->pickup_location->value(basket::getPickupLocation()); $form->configure->order_prefix->value(basket::getOrderPrefix()); $form->configure->order_bankaccount->value(basket::getOrderBankAccount()); $form->configure->order_accountowner->value(basket::getOrderAccountOwner()); }
function validate_ipn($key) { // parse the paypal URL $url_parsed = parse_url($this->paypal_url); // generate the post string from the _POST vars aswell as load the // _POST vars into an arry so we can play with them from the calling // script. $post_string = 'cmd=_notify-validate'; foreach ($_POST as $field => $value) { $this->ipn_data["{$field}"] = $value; $value = urlencode(stripslashes($value)); $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i', '${1}%0D%0A${3}', $value); $post_string .= '&' . $field . '=' . $value; } // open the connection to paypal $fp = fsockopen($this->secure_url, 443, $err_num, $err_str, 30); if (!$fp) { // could not open the connection. If loggin is on, the error message // will be in the log. $this->last_error = "fsockopen error no. {$errnum}: {$errstr}"; $this->log_ipn_results($key, false); return false; } else { // Post the data back to paypal fputs($fp, "POST " . $url_parsed['path'] . " HTTP/1.1\r\n"); fputs($fp, "Host: " . $url_parsed['host'] . "\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($post_string) . "\r\n\r\n"); //fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); // loop through the response from the server and append to variable while (!feof($fp)) { $this->ipn_response .= fgets($fp, 1024); } fclose($fp); // close connection } if (stristr($this->ipn_response, "VERIFIED") === false) { // Invalid IPN transaction. Check the log for details. $this->last_error = 'IPN Validation Failed. ' . $url_parsed['host'] . '\\' . $url_parsed['path']; $this->log_ipn_results($key, false); return false; } else { // Valid IPN transaction. // check recievers e-mail $business = basket::getPaypalAccount(); if ($this->ipn_data['receiver_email'] != $business) { $this->last_error = 'receivers e-mail did not match ' . $business; $this->log_ipn_results($key, false); return false; } // if confirmed check message has not been received already if ($this->ipn_data['payment_status'] == "Completed") { $message = ORM::factory("ipn_message")->where('key', "=", $key)->where('status', "=", 'completed')->where('txn_id', "=", $this->ipn_data['txn_id'])->find(); if ($message->loaded()) { $this->last_error = 'Message alread received.'; $this->log_ipn_results($key, false); return false; } } $this->log_ipn_results($key, true); return true; } }