/**
  * Add Payment
  *
  * Create a PaymentDBO and add it to the database
  */
 function add_payment()
 {
     // If the use entered the Invoice ID directly, use that.  Otherwise, use the
     // Invoice selected from the drop-down menu
     $invoice = isset($this->post['invoiceint']) ? $this->post['invoiceint'] : $this->post['invoiceselect'];
     // Create a new payment DBO
     $payment_dbo = new PaymentDBO();
     $payment_dbo->setInvoiceID($invoice->getID());
     $payment_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $payment_dbo->setAmount($this->post['amount']);
     $payment_dbo->setType($this->post['type']);
     $payment_dbo->setTransaction1($this->post['transaction1']);
     $payment_dbo->setTransaction2($this->post['transaction2']);
     $payment_dbo->setStatus($this->post['status']);
     // Insert Payment into database
     add_PaymentDBO($payment_dbo);
     // Success
     $this->setMessage(array("type" => "[PAYMENT_ENTERED]"));
     $this->reload();
 }
示例#2
0
 /**
  * Check Out
  */
 function checkout()
 {
     // The module must have been picked if this is not an existing customer
     if ($this->session['order']->getAccountType() == "New Account" && !isset($this->post['module'])) {
         throw new SWUserException("[YOU_MUST_SELECT_PAYMENT]");
     }
     // If required, make sure that the TOS box was checked
     if ($this->conf['order']['tos_required'] && !isset($this->post['accept_tos'])) {
         throw new SWUserException("[YOU_MUST_ACCEPT_THE_TERMS_OF_SERVICE]");
     }
     $this->session['order']->setRemoteIP(ip2long($_SERVER['REMOTE_ADDR']));
     $this->session['order']->setDateCreated(DBConnection::format_datetime(time()));
     $this->session['order']->setAcceptedTOS($this->post['accept_tos'] == "true" ? "Yes" : "No");
     /*
     if ( $this->session['order']->getAccountType() == "Existing Account" ) {
     	// Send existing accounts off to the receipt page
     	$this->session['order']->complete();
     	$this->gotoPage( "receipt" );
     }
     */
     // Register the new user
     if ($this->session['order']->getAccountType() == "New Account") {
         $order = $this->session['order'];
         $user_dbo = new UserDBO();
         // User-defined data
         $user_dbo->setUsername($order->getUsername());
         $user_dbo->setPassword($order->getPassword());
         $user_dbo->setContactName($order->getContactName());
         $user_dbo->setEmail($order->getContactEmail());
         // Admin-defined data
         $user_dbo->setType("Client");
         $user_dbo->setLanguage("english");
         // could change to user-defined
         $user_dbo->setTheme("default");
         add_UserDBO($user_dbo);
         // Add account info to accountDBO
         $account_dbo = new AccountDBO();
         $account_dbo->setStatus("Active");
         $account_dbo->setType("Individual Account");
         $account_dbo->setBillingStatus("Bill");
         $account_dbo->setBillingDay(1);
         $account_dbo->setBusinessName($order->getBusinessName());
         $account_dbo->setContactName($order->getContactName());
         $account_dbo->setContactEmail($order->getContactEmail());
         $account_dbo->setAddress1($order->getAddress1());
         $account_dbo->setAddress2($order->getAddress2());
         $account_dbo->setCity($order->getCity());
         $account_dbo->setState($order->getState());
         $account_dbo->setCountry($order->getCountry());
         $account_dbo->setPostalCode($order->getPostalCode());
         $account_dbo->setPhone($order->getPhone());
         $account_dbo->setMobilePhone($order->getMobilePhone());
         $account_dbo->setFax($order->getFax());
         $account_dbo->setUsername($order->getUsername());
         add_AccountDBO($account_dbo);
         $this->session['order']->setAccountID($account_dbo->getID());
     }
     // If the order does not have an ID already, save it to the database
     if ($this->session['order']->getID() == null) {
         add_OrderDBO($this->session['order']);
     }
     if ($this->session['review']['module'] == "Check") {
         // Record the promise to pay by check
         $checkPayment = new PaymentDBO();
         $checkPayment->setOrderID($this->session['order']->getID());
         $checkPayment->setAmount($this->session['order']->getTotal());
         $checkPayment->setStatus("Pending");
         $checkPayment->setDate(DBConnection::format_datetime(time()));
         $checkPayment->setType("Check");
         add_PaymentDBO($checkPayment);
         // Goto the receipt page
         $this->session['order']->complete();
         $this->gotoPage("receipt", null, "payByCheck=1");
     }
     // Collect Payment
     $registry = ModuleRegistry::getModuleRegistry();
     $paymentModule = $registry->getModule($this->post['module']);
     $checkoutPage = $paymentModule->getType() == "payment_processor" ? $paymentModule->getOrderCheckoutPage() : "ccpayment";
     // Redirect to the module's checkout page
     $_SESSION['module'] = $paymentModule;
     $this->gotoPage($checkoutPage);
 }
 /**
  * Add Payment
  *
  * Create a new PaymentDBO and add it to the database
  */
 function add_payment()
 {
     // Create a new payment DBO
     $invoice_id = isset($this->get['invoice']) ? $this->get['invoice']->getID() : $this->session['new_payment']['invoice']->getID();
     $payment_dbo = new PaymentDBO();
     $payment_dbo->setInvoiceID($invoice_id);
     $payment_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $payment_dbo->setAmount($this->post['amount']);
     $payment_dbo->setType($this->post['type']);
     $payment_dbo->setStatus("Completed");
     $payment_dbo->setTransaction1($this->post['transaction1']);
     $payment_dbo->setTransaction2($this->post['transaction2']);
     // Insert Payment into database
     add_PaymentDBO($payment_dbo);
     // Success
     $this->setMessage(array("type" => "[PAYMENT_ENTERED]"));
     $this->gotoPage("billing_view_invoice", null, "invoice=" . $payment_dbo->getInvoiceID());
 }
 /**
  * Process Credit Card Payment
  */
 function processCard()
 {
     // Update contact information
     $billingContact = new ContactDBO($this->post['contactname'], null, null, $this->post['address1'], $this->post['address2'], $this->post['city'], $this->post['state'], $this->post['postalcode'], $this->post['country'], $this->post['phone'], null, null);
     // Format the expire date
     $expireDate = date("my", $this->post['cardexpire']);
     // Create a new Payment DBO and process the payment
     $paymentDBO = new PaymentDBO();
     $paymentDBO->setType("Module");
     $paymentDBO->setModule($_SESSION['module']->getName());
     $paymentDBO->setOrderID($this->session['order']->getID());
     $paymentDBO->setAmount($this->session['order']->getTotal());
     $paymentDBO->setStatus("Pending");
     if (!$paymentDBO->processCreditCard($billingContact, $this->post['cardnumber'], $expireDate, $this->post['cardcode'], $this->conf['payment_gateway']['order_method'])) {
         print "card error";
         $this->setError(array("type" => "[CC_PROCESSING_ERROR]"));
         $this->reload();
     }
     // Card processed, save the payment DBO
     add_PaymentDBO($paymentDBO);
     // Complete the order
     $_SESSION['order']->complete();
     // Show receipt
     $this->gotoPage("receipt");
 }
示例#5
0
 /**
  * Create a New Payment DBO and save it to the database
  *
  * @param string $status SolidState's Payment status (THIS IS NOT $_POST['payment_status'])
  */
 function newPayment($status)
 {
     // Construct a new Payment DBO
     $this->paymentDBO = new PaymentDBO();
     $this->paymentDBO->setDate(DBConnection::format_datetime(time()));
     $this->paymentDBO->setAmount($_POST['mc_gross']);
     $this->paymentDBO->setTransaction1($_POST['txn_id']);
     $this->paymentDBO->setTransaction2($_POST['payer_email']);
     $this->paymentDBO->setType("Module");
     $this->paymentDBO->setModule($this->ppModule->getName());
     $this->paymentDBO->setStatus($status);
     if (isset($_POST['custom'])) {
         // This IPN contains an order ID
         $this->paymentDBO->setOrderID(intval($_POST['custom']));
     }
     if (isset($_POST['invoice'])) {
         // This IPN contains an invoice ID
         $this->paymentDBO->setInvoiceID(intval($_POST['invoice']));
     }
     // Add the Payment DBO to the database
     add_PaymentDBO($this->paymentDBO);
     // Log the new payment
     log_notice("PSIPNPage::newPayment()", sprintf("New payment received from Paypal.  Order ID=%d, TXN=%s, Customer=%s, Amount=%s, Paypal Status=%s", intval($_POST['custom']), $_POST['txn_id'], $_POST['payer_email'], $_POST['mc_gross'], $_POST['payment_status']));
 }