/** * confirm payment for order * * @param string $id_order [unique indentifier of order] * @param string $txn_id id of the transaction depending on provider */ public function confirm_payment($paymethod = 'paypal', $txn_id = NULL) { // update orders if ($this->loaded()) { $this->status = self::STATUS_PAID; $this->pay_date = Date::unix2mysql(); $this->paymethod = $paymethod; $this->txn_id = $txn_id; try { $this->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } //if saved delete coupon from session and -- number of coupons. Model_Coupon::sale($this->coupon); //for membership plans if ($this->id_product >= 100) { Model_Subscription::new_order($this); $replace_email = array('[AD.TITLE]' => $this->description, '[URL.AD]' => Route::url('pricing'), '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product, '[VAT.COUNTRY]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_country : '', '[VAT.NUMBER]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_number : '', '[VAT.PERCENTAGE]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT : ''); } else { $ad = $this->ad; //depending on the product different actions switch ($this->id_product) { case Model_Order::PRODUCT_AD_SELL: $ad->sale($this); break; case Model_Order::PRODUCT_TO_TOP: $ad->to_top(); break; case Model_Order::PRODUCT_TO_FEATURED: $ad->to_feature($this->featured_days); Social::social_post_featured_ad($ad); break; case Model_Order::PRODUCT_CATEGORY: $ad->paid_category(); break; } $url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)); $replace_email = array('[AD.TITLE]' => $ad->title, '[URL.AD]' => $url_ad, '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product, '[VAT.COUNTRY]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_country : '', '[VAT.NUMBER]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT_number : '', '[VAT.PERCENTAGE]' => (isset($this->VAT) and $this->VAT > 0) ? $this->VAT : ''); } //send email to site owner! new sale!! if (core::config('email.new_ad_notify') == TRUE) { Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads-sold', $replace_email); } } }
/** * confirm payment for order * * @param string $id_order [unique indentifier of order] * @param string $txn_id id of the transaction depending on provider */ public function confirm_payment($paymethod = 'paypal', $txn_id = NULL) { // update orders if ($this->loaded()) { $ad = $this->ad; $this->status = self::STATUS_PAID; $this->pay_date = Date::unix2mysql(); $this->paymethod = $paymethod; $this->txn_id = $txn_id; try { $this->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } //if saved delete coupon from session and -- number of coupons. Model_Coupon::sale($this->coupon); //send email to site owner! new sale!! if (core::config('email.new_ad_notify') == TRUE) { $url_ad = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)); $replace = array('[AD.TITLE]' => $ad->title, '[URL.AD]' => $url_ad, '[ORDER.ID]' => $this->id_order, '[PRODUCT.ID]' => $this->id_product); Email::content(core::config('email.notify_email'), core::config('general.site_name'), core::config('email.notify_email'), core::config('general.site_name'), 'ads-sold', $replace); } //depending on the product different actions switch ($this->id_product) { case Model_Order::PRODUCT_AD_SELL: $ad->sale($this); break; case Model_Order::PRODUCT_TO_TOP: $ad->to_top(); break; case Model_Order::PRODUCT_TO_FEATURED: $ad->to_feature($this->featured_days); break; case Model_Order::PRODUCT_CATEGORY: $ad->paid_category(); break; } } }
/** * confirm payment for order * * @param string $id_order [unique indentifier of order] * @param string $txn_id id of the transaction depending on provider */ public function confirm_payment($paymethod = 'paypal', $txn_id = NULL, $pay_date = NULL, $amount = NULL, $currency = NULL) { // update orders if ($this->loaded()) { $product = $this->product; $user = $this->user; $this->status = self::STATUS_PAID; $this->pay_date = $pay_date === NULL ? Date::unix2mysql() : $pay_date; $this->paymethod = $paymethod; $this->txn_id = $txn_id; if ($product->support_days > 0) { $this->support_date = Date::unix2mysql(Date::mysql2unix($this->pay_date) + $product->support_days * 24 * 60 * 60); } if ($amount !== NULL) { $this->amount = $amount; } if ($currency !== NULL) { $this->currency = $currency; } try { $this->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } //if saved delete coupon from session and -- number of coupons. Model_Coupon::sale($this->coupon); //add affiliate commision Model_Affiliate::sale($this, $product); //generate licenses $licenses = Model_License::generate($user, $this, $product); $license = ''; //loop all the licenses to an string if (count($licenses) > 0) { $license = '\\n\\n==== ' . __('Your Licenses') . ' ===='; foreach ($licenses as $l) { $license .= '\\n' . $l->license; } } //download link $download = ''; if ($product->has_file() == TRUE) { $dwnl_link = $user->ql('oc-panel', array('controller' => 'profile', 'action' => 'download', 'id' => $this->id_order)); $download = '\\n\\n==== ' . __('Download') . ' ====\\n<a href="' . $dwnl_link . '">' . $dwnl_link . '</a>'; } //theres an expire? 0 = unlimited $expire = ''; $expire_hours = Core::config('product.download_hours'); $expire_times = Core::config('product.download_times'); if (($expire_hours > 0 or $expire_times > 0) and $product->has_file() == TRUE) { if ($expire_hours > 0 and $expire_times > 0) { $expire = sprintf(__('Your download expires in %u hours and can be downloaded %u times.'), $expire_hours, $expire_times); } elseif ($expire_hours > 0) { $expire = sprintf(__('Your download expires in %u hours.'), $expire_hours); } elseif ($expire_times > 0) { $expire = sprintf(__('Can be downloaded %u times.'), $expire_times); } $expire = '\\n' . $expire; } //param for sale email $params = array('[DATE]' => $this->pay_date, '[ORDER.ID]' => $this->id_order, '[USER.NAME]' => $user->name, '[USER.EMAIL]' => $user->email, '[PRODUCT.TITLE]' => $product->title, '[PRODUCT.PRICE]' => i18n::format_currency($this->amount, $this->currency), '[PRODUCT.NOTES]' => Text::bb2html($product->email_purchase_notes, TRUE, FALSE, FALSE), '[DOWNLOAD]' => $download, '[EXPIRE]' => $expire, '[LICENSE]' => $license); //send email with order details download link and product notes $user->email('new-sale', $params); //notify to seller if (core::config('email.new_sale_notify')) { Email::send(core::config('email.notify_email'), '', 'New Sale! ' . $product->title, 'New Sale! ' . $product->title, core::config('email.notify_email'), ''); } return TRUE; } return FALSE; }