/** * Fills object with all standard items of a Notification record * * @param cbpaidPayHandler $payHandler * @param int $test_ipn * @param string $log_type * @param string $paymentStatus * @param string $paymentType * @param string $reasonCode * @param int $paymentTime * @param string $charset */ public function initNotification($payHandler, $test_ipn, $log_type, $paymentStatus, $paymentType, $reasonCode, $paymentTime, $charset = 'utf-8') { $this->payment_method = $payHandler->getPayName(); $this->gateway_account = $payHandler->getAccountParam('id'); $this->log_type = $log_type; $this->time_received = Application::Database()->getUtcDateTime(); $this->ip_addresses = cbpaidRequest::getIPlist(); $this->geo_ip_country_code = cbpaidRequest::getGeoIpCountryCode(); $this->notify_version = '2.1'; $this->user_id = (int) cbGetParam($_GET, 'user', 0); $this->charset = $charset; $this->test_ipn = $test_ipn; $this->payer_status = 'unverified'; $this->payment_status = $paymentStatus; if (in_array($paymentStatus, array('Completed', 'Pending', 'Processed', 'Failed', 'Reversed', 'Refunded', 'Partially-Refunded', 'Canceled_Reversal'))) { if (in_array($paymentStatus, array('Completed', 'Reversed', 'Refunded', 'Partially-Refunded', 'Canceled_Reversal'))) { $this->payment_date = gmdate('H:i:s M d, Y T', $paymentTime); // paypal-style } $this->payment_type = $paymentType; } if ($reasonCode) { $this->reason_code = $reasonCode; } }
/** * create a paymentBasket in database * * @param UserTable $user * @param float $price * @param string $currency * @param int $quantity * @param string $item_number * @param string $item_name * @param boolean $store default: TRUE: store object in database, FALSE: keep in memory only * @param int $now unix time * @param int $owner basket owner (seller) * @param string $reason payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update */ public function createPaymentBasket($user, $price, $currency, $quantity, $item_number, $item_name, $store, $now, $owner, $reason) { global $_CB_database; $this->reset(); $this->user_id = (int) $user->id; $this->owner = (int) $owner; $this->payment_status = 'NotInitiated'; $this->time_initiated = $_CB_database->getUtcDateTime($now); $this->ip_addresses = cbpaidRequest::getIPlist(); $this->geo_ip_country_code = cbpaidRequest::getGeoIpCountryCode(); $this->mc_gross = $price; // for now, later sum... $this->mc_currency = $currency; $this->quantity = $quantity; $this->item_number = $item_number; $this->item_name = $item_name; $this->setRandom_shared_secret(); $this->_setInvoicingAddress($user); if ($store) { $this->historySetMessage('Creating new payment basket'); if (!$this->store()) { trigger_error('payment_basket store error:' . htmlspecialchars($_CB_database->getErrorMsg()), E_USER_ERROR); } } }
/** * Returns default invoice country code of this user * * @param boolean $onlyGeoIp * @return string|null */ public function getDefaultInvoiceCountryCode($onlyGeoIp = true) { $buyerCountryCode = cbpaidRequest::getGeoIpCountryCode(); if ($buyerCountryCode) { return $buyerCountryCode; } if ($onlyGeoIp) { return null; } $params = cbpaidApp::settingsParams(); if ($params->get('integration_cbsubstax_enabled') != 1) { return null; } return $params->get('integration_cbsubstax_system_buyer_country_iso_code2'); }