/**
  *
  * @param User 
  * @param Am_Paysystem_Abstract $payplugin
  * @param array $product_ids array of product_id to use for generation
  * @param int $invCnt count of invoices per user
  * @param int $invVar variation of count of invoices per user
  * @param int $prdCnt count of products per invoice
  * @param int $prdVar variation of products per invoice 
  */
 public function createInvoices($user, $payplugin, $product_ids, $invCnt, $invVar, $prdCnt, $prdVar)
 {
     $invoiceLimit = $this->getLimit($invCnt, $invVar);
     for ($j = 1; $j <= $invoiceLimit; $j++) {
         //subscribe user for some subscriptions
         $invoice = $this->getDi()->invoiceTable->createRecord();
         $productLimit = $this->getLimit($prdCnt, $prdVar);
         for ($k = 1; $k <= $productLimit; $k++) {
             $invoice->add(Am_Di::getInstance()->productTable->load(array_rand($product_ids)), 1);
         }
         $invoice->setUser($user);
         $invoice->setPaysystem($payplugin->getId());
         $invoice->calculate();
         $invoice->save();
         $transaction = new Am_Paysystem_Transaction_Manual($payplugin);
         $transaction->setAmount($invoice->first_total)->setInvoice($invoice)->setTime(new DateTime('-' . rand(0, 200) . ' days'))->setReceiptId('demo-' . uniqid() . microtime(true));
         $invoice->addPayment($transaction);
         //            $cc = $this->createCcRecord($user);
         //
         //            Am_Paysystem_Transaction_CcDemo::_setTime(new DateTime('-'.rand(0,200).' days'));
         //            $payplugin->doBill($invoice, true, $cc);
         $transaction = null;
         unset($transaction);
         $invoice = null;
         unset($invoice);
     }
 }
Пример #2
0
 public function __construct(Am_Paysystem_Abstract $plugin, Am_Request $request, Zend_Controller_Response_Http $response, $invokeArgs)
 {
     $DR = preg_replace("/\\s/", "+", $request->get('DR', $_GET['DR']));
     $rc4 = new Crypt_RC4($plugin->getConfig('secret', 'ebskey'));
     $QueryString = base64_decode($DR);
     $rc4->decrypt($QueryString);
     $QueryString = split('&', $QueryString);
     foreach ($QueryString as $param) {
         $param = split('=', $param);
         $request->setParam($param[0], $param[1]);
     }
     parent::__construct($plugin, $request, $request, $invokeArgs);
 }
Пример #3
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($invoice->rebill_times) {
         return "Interkassa cannot handle products with recurring payment plan";
     }
     return parent::isNotAcceptableForInvoice($invoice);
 }
Пример #4
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($invoice->rebill_times && $invoice->first_period != $invoice->second_period) {
         return "WorldPay cannot handle products with different first and second period";
     }
     return parent::isNotAcceptableForInvoice($invoice);
 }
Пример #5
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     list($action, $status, $id) = explode("-", $request->getActionName());
     if ($action != 'status') {
         if ($action != 'ipn' && $action != 'thanks' || $request->get('transaction_status') == 'SETTLED') {
             parent::directAction($request, $response, $invokeArgs);
         }
         return;
     }
     if (!in_array($status, array('return', 'ok', 'fail'))) {
         throw new Am_Exception_InternalError("Bad status-request {$status}");
     }
     if (!$id) {
         throw new Am_Exception_InternalError("Invoice ID is absent");
     }
     if (!($this->invoice = $this->getDi()->invoiceTable->findFirstByPublicId($id))) {
         throw new Am_Exception_InternalError("Invoice not found by id [{$id}]");
     }
     switch ($status) {
         case 'return':
             $url = $request->get('transactionStatus') == 'REJECTED' ? $this->getCancelUrl() : $this->getReturnUrl();
             break;
         case 'ok':
             $url = $this->getReturnUrl();
             break;
         case 'fail':
             $url = $this->getCancelUrl();
             break;
     }
     $response->setRedirect($url);
 }
Пример #6
0
 function init()
 {
     parent::init();
     $this->getDi()->productTable->customFields()->add(new Am_CustomFieldText('web_id', '2000Charge.com website ID'));
     $this->getDi()->productTable->customFields()->add(new Am_CustomFieldText(self::PRICEPOINT, 'Mapping code given by 2000Charge'));
     $this->getDi()->productTable->customFields()->add(new Am_CustomFieldSelect('payment_option', 'Payment Option', 'Display Only Specified Payment Options', null, array('options' => $this->payment_options)));
 }
Пример #7
0
 function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getActionName() == 'ipn') {
         echo 'OK';
     }
     return parent::directAction($request, $response, $invokeArgs);
 }
Пример #8
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getFiltered('INVNUM', $request->getFiltered('INVOICE')) == '') {
         $response->setRedirect($this->getRootUrl() . '/thanks');
     } else {
         parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #9
0
 function init()
 {
     parent::init();
     $opt = array('' => 'Using plugin settings');
     if ($this->isConfigured()) {
         Am_Di::getInstance()->productTable->customFields()->add(new Am_CustomFieldSelect('bitpay_speed_risk', 'Bitpay speed/risk', null, null, array('options' => $opt + $this->transactionSpeedOptions)));
     }
 }
Пример #10
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getActionName() == 'thanks') {
         return $this->thanksAction($request, $response, $invokeArgs);
     } else {
         return parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #11
0
 /**
  *
  * @param User
  * @param Am_Paysystem_Abstract $payplugin
  * @param array $product_ids array of product_id to use for generation
  * @param int $invCnt count of invoices per user
  * @param int $invVar variation of count of invoices per user
  * @param int $prdCnt count of products per invoice
  * @param int $prdVar variation of products per invoice
  * @param int $start timestamp period begin
  * @param int $end timestamp period end
  */
 public function createInvoices($user, $payplugin, $product_ids, $invCnt, $invVar, $prdCnt, $prdVar, $start, $end, $coupons = array())
 {
     $invoiceLimit = $this->getLimit($invCnt, $invVar);
     for ($j = 1; $j <= $invoiceLimit; $j++) {
         $tm = mt_rand($start, $end);
         /* @var $invoice Invoice */
         $invoice = $this->getDi()->invoiceTable->createRecord();
         $productLimit = max(1, $this->getLimit($prdCnt, $prdVar));
         for ($k = 1; $k <= $productLimit; $k++) {
             try {
                 $product = Am_Di::getInstance()->productTable->load(array_rand($product_ids));
                 if (!($err = $invoice->isProductCompatible($product))) {
                     $invoice->add($product, 1);
                 }
             } catch (Am_Exception_InputError $e) {
             }
         }
         if (!count($invoice->getItems())) {
             continue;
         }
         if (count($coupons) && rand(1, 5) == 5) {
             $invoice->setCouponCode($coupons[array_rand($coupons)]);
             $invoice->validateCoupon();
         }
         $invoice->tm_added = sqlTime($tm);
         $invoice->setUser($user);
         $invoice->calculate();
         $invoice->setPaysystem($payplugin->getId());
         $invoice->save();
         $this->getDi()->setService('dateTime', new DateTime('@' . $tm));
         if ($invoice->isZero()) {
             $tr = new Am_Paysystem_Transaction_Free($this->getDi()->plugins_payment->loadGet('free'));
             $tr->setInvoice($invoice)->setTime(new DateTime('@' . $tm))->process();
         } else {
             $tr = new Am_Paysystem_Transaction_Manual($payplugin);
             $tr->setAmount($invoice->first_total)->setInvoice($invoice)->setTime(new DateTime('@' . $tm))->setReceiptId('demo-' . substr(sprintf('%.4f', microtime(true)), -7))->process();
             //recurring payments
             $i = 1;
             while ((double) $invoice->second_total && $invoice->rebill_date < sqlDate($end) && $invoice->rebill_times >= $i && !$invoice->isCancelled()) {
                 $this->getDi()->setService('dateTime', new DateTime('@' . amstrtotime($invoice->rebill_date)));
                 $tr = new Am_Paysystem_Transaction_Manual($payplugin);
                 $tr->setAmount($invoice->second_total)->setInvoice($invoice)->setTime(new DateTime('@' . amstrtotime($invoice->rebill_date)))->setReceiptId('demo-rebill-' . $i++ . '-' . substr(sprintf('%.4f', microtime(true)), -7))->process();
                 if (rand(1, 5) == 5) {
                     //20% probability
                     $invoice->setCancelled(true);
                 }
             }
             //            $cc = $this->createCcRecord($user);
             //
             //            Am_Paysystem_Transaction_CcDemo::_setTime(new DateTime('-'.rand(0,200).' days'));
             //            $payplugin->doBill($invoice, true, $cc);
         }
         $tr = null;
         unset($tr);
         $invoice = null;
         unset($invoice);
     }
 }
Пример #12
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         parent::directAction($request, $response, $invokeArgs);
     } catch (Am_Exception_Paysystem_TransactionInvalid $ex) {
         //nothing
     }
     echo 'ok';
 }
Пример #13
0
 function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         parent::directAction($request, $response, $invokeArgs);
     } catch (Exception $e) {
         $this->getDi()->errorLogTable->logException($e);
     }
     echo "<!--success-->";
 }
Пример #14
0
 public function _initSetupForm(Am_Form_Setup $form)
 {
     $form->addText('vendor_name')->setLabel(array('Client ID', 'Your Client ID will be supplied when your service is activated. 
                                         It will be in the format “ABC01”, where ABC is your organisation’s
                                         unique three letter code. 
                                         It is used for logging into the NAB Transact administration, reporting and search tool.'));
     $form->addAdvCheckbox('testing')->setLabel('Test Mode');
     parent::_initSetupForm($form);
 }
Пример #15
0
 function getConfig($key = null, $default = null)
 {
     switch ($key) {
         case 'auto_create':
             return true;
         default:
             return parent::getConfig($key, $default);
     }
 }
Пример #16
0
 public function __construct(Am_Di $di, array $config)
 {
     parent::__construct($di, $config);
     foreach ($di->paysystemList->getList() as $k => $p) {
         if ($p->getId() == $this->getId()) {
             $p->setPublic(false);
         }
     }
     $di->billingPlanTable->customFields()->add(new Am_CustomFieldText('limelight_product_id', "Limelight Product Id", "", array()));
 }
Пример #17
0
 function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         parent::directAction($request, $response, $invokeArgs);
     } catch (Am_Exception $e) {
         $this->getDi()->errorLogTable->logException($e);
         print "OK";
         exit;
     }
 }
Пример #18
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ('reject' == $request->getActionName()) {
         $invoice = $this->getDi()->invoiceTable->findFirstByPublicId($request->get("orderDescription"));
         $url = $this->getRootUrl() . "/cancel?id=" . $invoice->getSecureId('CANCEL');
         return Am_Controller::redirectLocation($url);
     } else {
         return parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #19
0
 function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         parent::directAction($request, $response, $invokeArgs);
     } catch (Exception $e) {
         $this->getDi()->errorLogTable->logException($e);
         $response->setRawHeader('HTTP/1.1 600 user-error');
         $response->setBody("Error: " . $e->getMessage());
     }
 }
Пример #20
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     try {
         parent::directAction($request, $response, $invokeArgs);
     } catch (Exception $e) {
         $this->getDi()->errorLogTable->logException($e);
     }
     //in other case blockchain will send IPN's once per minute
     echo 'ok';
 }
Пример #21
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($err = parent::isNotAcceptableForInvoice($invoice)) {
         return $err;
     }
     if ($invoice->rebill_times >= 1 && ($err = $this->checkPeriod(new Am_Period($invoice->first_period)))) {
         return array($err);
     }
     if ($invoice->rebill_times >= 2 && ($err = $this->checkPeriod(new Am_Period($invoice->second_period)))) {
         return array($err);
     }
 }
Пример #22
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getActionName() == 'refund') {
         echo "OK";
         ob_flush();
         return $this->refundAction($request, $response, $invokeArgs);
     } else {
         echo "<softshop></softshop>";
         ob_flush();
         parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #23
0
 public function __construct(Am_Di $di, array $config)
 {
     parent::__construct($di, $config);
     foreach ($di->paysystemList->getList() as $k => $p) {
         if ($p->getId() == $this->getId()) {
             $p->setPublic(false);
         }
     }
     $di->billingPlanTable->customFields()->add(new Am_CustomFieldText('nanacast_product_id', 'Nanacast Product ID used for Advanced API', '%Your Product/Podcast/RSS Feed/Membership ID% <br />
          (you can find this ID by clicking on "Edit Listing" 
          for your particular Product/Podcast/RSS Feed/Membership. 
          At the top there is a field that says "ID used for Advanced API'));
 }
Пример #24
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $actionName = $request->getActionName();
     if ($actionName == 'fail') {
         $invoice = $this->getDi()->invoiceTable->findFirstByPublicId($request->getParam('m_orderid'));
         if (!$invoice) {
             throw new Am_Exception_InputError();
         }
         return Am_Controller::redirectLocation($this->getRootUrl() . "/cancel?id=" . $invoice->getSecureId('CANCEL'));
     } else {
         return parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #25
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getActionName() == 'thanks') {
         if ($this->getConfig('debugLog')) {
             Am_Di::getInstance()->errorLogTable->log('NetBilling Form [response-thanks]:' . json_encode($request->getParams()));
         }
         $this->invoice = $this->getDi()->invoiceTable->findFirstByPublicId($request->getFiltered('Ecom_ConsumerOrderID'));
         $url = $request->get('Ecom_Ezic_Response_StatusCode') == 0 || $request->get('Ecom_Ezic_Response_StatusCode') == 'F' ? $this->getCancelUrl() : $this->getReturnUrl();
         $response->setRedirect($url);
     } else {
         parent::directAction($request, $response, $invokeArgs);
     }
 }
Пример #26
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($request->getActionName() == 'api' && ($api_resend = $this->getConfig('api_resend'))) {
         try {
             $client = new Am_HttpRequest($api_resend, Am_HttpRequest::METHOD_POST);
             $client->setHeader('Content-type', 'text/xml');
             $client->setBody($request->getRawBody());
             $response = $client->send();
         } catch (Exception $e) {
             $this->getDi()->errorLogTable->logException($e);
         }
     }
     parent::directAction($request, $response, $invokeArgs);
 }
Пример #27
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($invoice->first_period != $invoice->second_period) {
         return ___('Can not handle this billing terms');
     }
     if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) {
         return ___('Can not handle this billing terms');
     }
     $period = new Am_Period($invoice->first_period);
     if (!in_array($period->getUnit(), array('m', 'w', 'y')) || $period->getCount() != 1) {
         return ___('Can not handle this billing terms');
     }
     return parent::isNotAcceptableForInvoice($invoice);
 }
Пример #28
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($err = parent::isNotAcceptableForInvoice($invoice)) {
         return $err;
     }
     if ($invoice->rebill_times >= 1 && ($err = $this->checkPeriod(new Am_Period($invoice->first_period)))) {
         return array($err);
     }
     if ($invoice->rebill_times >= 2 && ($err = $this->checkPeriod(new Am_Period($invoice->second_period)))) {
         return array($err);
     }
     if ($invoice->rebill_times != IProduct::RECURRING_REBILLS && $invoice->rebill_times > 52) {
         return array('PayPal can not handle subscription terms with number of rebills more than 52');
     }
 }
Пример #29
0
 /**
  * Send response handle failure, return parsed array
  * @return array 
  */
 public function sendRequest(InvoiceLog $log)
 {
     $log->paysys_id = $this->plugin->getId();
     $log->add($this);
     $response = $this->send();
     $log->add($response);
     if ($response->getStatus() != 200) {
         throw new Am_Exception_InputError("Error communicating to PayPal, unable to finish transaction. Your account was not billed, please try again");
     }
     parse_str($response->getBody(), $vars);
     if (!count($vars)) {
         throw new Am_Exception_InputError("Error communicating to PayPay, unable to parse response ");
     }
     return $vars;
 }
Пример #30
0
 public function isNotAcceptableForInvoice(Invoice $invoice)
 {
     if ($invoice->rebill_times) {
         $first_period = new Am_Period($invoice->first_period);
         if (!(double) $invoice->first_total) {
             return ___('Can not handle this billing terms');
         }
         if ($invoice->first_period != $invoice->second_period && $first_period->getUnit() != 'd') {
             return ___('Can not handle this billing terms');
         }
         if (!in_array($invoice->second_period, array_keys($this->rebill_type_map))) {
             return ___('Can not handle this billing terms');
         }
     }
     return parent::isNotAcceptableForInvoice($invoice);
 }