/** * @param object $oMembership The Object Membership Model. * @return void */ public function button2CheckOut($oMembership) { $o2CO = new TwoCO($this->config->values['module.setting']['sandbox.enabled']); $o2CO->param('sid', $this->config->values['module.setting']['2co.vendor_id'])->param('id_type', 1)->param('cart_order_id', $oMembership->groupId)->param('merchant_order_id', $oMembership->groupId)->param('c_prod', $oMembership->groupId)->param('c_price', $oMembership->price)->param('total', $oMembership->price)->param('c_name', $this->registry->site_name . ' ' . $oMembership->name)->param('tco_currency', $this->config->values['module.setting']['currency'])->param('c_tangible', 'N')->param('x_receipt_link_url', Uri::get('payment', 'main', 'process', '2co')); echo '<form action="', $o2CO->getUrl(), '" method="post">', $o2CO->generate(), '<button type="submit" name="submit">', static::buyTxt($oMembership->name, '2CO'), '</button> </form>'; unset($o2CO); }
public function process($sProvider = '') { switch ($sProvider) { case 'paypal': $oPayPal = new PayPal($this->config->values['module.setting']['sandbox.enabled']); if ($oPayPal->valid() && $this->httpRequest->postExists('item_number') && $this->httpRequest->postExists('custom')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->httpRequest->post('custom', 'int'), $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK // PayPal will call automatically the "notification()" method thanks its IPN feature and "notify_url" form attribute. } } unset($oPayPal); break; case 'stripe': if ($this->httpRequest->postExists('stripeToken')) { \Stripe\Stripe::setApiKey($this->config->values['module.setting']['stripe.secret_key']); $oCharge = \Stripe\Charge::create(array('source' => $this->httpRequest->post('stripeToken'), 'email' => $this->httpRequest->post('stripeEmail'))); if ($this->oUserModel->updateMembership($this->httpRequest->post('item_number'), $this->httpRequest->post('member_id', 'int'), $this->httpRequest->post('amount'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK $this->notification('Stripe'); // Add info into the log file } } break; case '2co': $o2CO = new TwoCO($this->config->values['module.setting']['sandbox.enabled']); $sVendorId = $this->config->values['module.setting']['2co.vendor_id']; $sSecretWord = $this->config->values['module.setting']['2co.secret_word']; if ($o2CO->valid($sVendorId, $sSecretWord) && $this->httpRequest->postExists('sale_id')) { if ($this->oUserModel->updateMembership($this->httpRequest->post('sale_id'), $this->iProfileId, $this->httpRequest->post('price'), $this->dateTime->dateTime('Y-m-d H:i:s'))) { $this->_bStatus = true; // Status is OK $this->notification('TwoCO'); // Add info into the log file } } unset($o2CO); break; case 'ccbill': // In developing... // Contact us at <*****@*****.**> or <*****@*****.**> if you want to help us by developing the payment system CCBill break; default: $this->displayPageNotFound(t('Provinder Not Found!')); } // Set the page titles $this->sTitle = $this->_bStatus ? t('Thank you!') : t('Error occurred!'); $this->view->page_title = $this->sTitle; $this->view->h2_title = $this->sTitle; if ($this->_bStatus) { $this->updateAffCom(); } // Set the valid page $sPage = $this->_bStatus ? 'success' : 'error'; $this->manualTplInclude($sPage . $this->view->getTplExt()); // Output $this->output(); }