예제 #1
0
 function indexAction()
 {
     $this->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
     $id = $this->_request->getFiltered('id');
     if (empty($id)) {
         $id = filterId(@$_GET['id']);
     }
     $this->invoice = null;
     if ($id) {
         $this->invoice = $this->getDi()->invoiceTable->findBySecureId($id, 'THANKS');
         if (!$this->invoice) {
             throw new Am_Exception_InputError("Invoice #{$id} not found");
         }
         $tm = max($this->invoice->tm_started, $this->invoice->tm_added);
         if ($this->getDi()->time - strtotime($tm) > 48 * 3600) {
             throw new Am_Exception_InputError("Link expired");
         }
         // Clean signup_member_login and signup_member_id to avoid duplicate signups with the same email address.
         $this->getSession()->signup_member_id = null;
         $this->getSession()->signup_member_login = null;
         $this->view->invoice = $this->invoice;
         foreach ($this->invoice->getPaymentRecords() as $p) {
             $this->view->payment = $p;
         }
         if (!$this->invoice->tm_started) {
             $this->view->show_waiting = true;
             $this->view->refreshTime = "<span id='am-countdown'>00:10</span> " . ___("seconds");
         }
         $this->view->script = $this->getJs(10);
     }
     $this->getDi()->hook->call(Am_Event::THANKS_PAGE, array('controller' => $this, 'invoice' => $this->invoice));
     $this->view->layoutNoMenu = true;
     $this->view->display('thanks.phtml');
 }
예제 #2
0
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $this->invoice = $invoice;
     list($payment) = $invoice->getPaymentRecords();
     $params = array('key' => $this->getConfig('key'), 'ref' => $payment->receipt_id, 'uid' => $payment->user_id, 'type' => 2);
     $params['sign'] = $this->calculateSignature($params, $this->getConfig('secret'));
     $requst = new Am_HttpRequest(self::URL_TICKET, Am_HttpRequest::METHOD_POST);
     $requst->addPostParameter($params);
     $log = $this->logRequest($requst);
     $responce = $requst->send();
     $log->add($responce);
     if ($responce->getStatus() != 200) {
         $result->setFailed('Incorrect HTTP response status: ' . $responce->getStatus());
         return;
     }
     $res = Am_Controller::decodeJson($responce->getBody());
     if ($res['result'] == 1) {
         $invoice->setCancelled();
         $result->setSuccess();
         return;
     }
     $result->setFailed($res['errors']);
 }
예제 #3
0
파일: wepay.php 프로젝트: grlf/eyedock
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     // get preapproval id from checkout id
     $payments = $invoice->getPaymentRecords();
     $params = array('checkout_id' => $payments[0]->receipt_id);
     $req = new Am_HttpRequest($this->getUrl() . "/checkout/", Am_HttpRequest::METHOD_POST);
     $req->setBody(json_encode($params));
     $req->setHeader("Content-Type", "application/json");
     $req->setHeader("Authorization", "Bearer " . $this->getConfig('token'));
     $res = $req->send();
     $arr = json_decode($res->getBody(), true);
     if ($res->getStatus() != 200) {
         Am_Di::getInstance()->errorLogTable->log("WEPAY API ERROR : {$arr['error_code']} - {$arr['error_description']}");
         return false;
     }
     if (!empty($arr['error_description'])) {
         return false;
     }
     //cancel preapproval
     $params = array('preapproval_id' => $arr['preapproval_id']);
     $req = new Am_HttpRequest($this->getUrl() . "/preapproval/cancel", Am_HttpRequest::METHOD_POST);
     $req->setBody(json_encode($params));
     $req->setHeader("Content-Type", "application/json");
     $req->setHeader("Authorization", "Bearer " . $this->getConfig('token'));
     $res = $req->send();
     $arr = json_decode($res->getBody(), true);
     if ($res->getStatus() != 200) {
         $this->getDi()->errorLogTable->log("WEPAY API ERROR : {$arr['error_code']} - {$arr['error_description']}");
         throw new Am_Exception_InputError(___("An error occurred while cancellation request"));
     }
     if ($arr['state'] != 'cancelled') {
         throw new Am_Exception_InputError(___("An error occurred while cancellation request"));
     }
 }
예제 #4
0
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $payment = current($invoice->getPaymentRecords());
     try {
         $this->cancelInvoice($payment, $result);
         $invoice->setCancelled(true);
     } catch (Exception $e) {
         $result->setFailed($e->getMessage());
     }
 }
예제 #5
0
 function doUpgrade(Invoice $invoice, InvoiceItem $item, Invoice $newInvoice, ProductUpgrade $upgrade)
 {
     if (!$this->getConfig('datalink_user') || !$this->getConfig('datalink_pass')) {
         $this->getDi()->errorLogTable->log("ccBill plugin error: Datalink is not configured!");
         return;
     }
     $payments = $invoice->getPaymentRecords();
     $subscriptionId = $payments[0]->transaction_id;
     $vars = array('clientAccnum' => $this->getConfig('account'), 'usingSubacc' => $this->getConfig('subaccount_id'), 'subscriptionId' => $subscriptionId, 'newClientAccnum' => $this->getConfig('account'), 'newClientSubacc' => $this->getConfig('subaccount_id'), 'sharedAuthentication' => 1, 'action' => 'chargeByPreviousTransactionId', 'currencyCode' => $this->currency_codes[$invoice->currency], 'initialPrice' => $newInvoice->first_total, 'initialPeriod' => $this->getDays($newInvoice->first_period), 'returnXML' => 1, 'username' => $this->getConfig('datalink_user'), 'password' => $this->getConfig('datalink_pass'));
     if ($newInvoice->rebill_times) {
         $vars['recurringPrice'] = $newInvoice->second_total;
         $vars['recurringPeriod'] = $this->getDays($newInvoice->second_period);
         $vars['rebills'] = $newInvoice->rebill_times == IProduct::RECURRING_REBILLS ? 99 : $newInvoice->rebill_times;
     } else {
         $vars['recurringPrice'] = 0;
         $vars['recurringPeriod'] = 0;
         $vars['rebills'] = 0;
     }
     $r = new Am_HttpRequest($requestString = "https://bill.ccbill.com/jpost/billingApi.cgi?" . http_build_query($vars, '', '&'));
     $response = $r->send();
     if (!$response) {
         $this->getDi()->errorLogTable->log('ccBill Billing API  error: Unable to contact datalink server');
         throw new Am_Exception_InternalError('ccBill Billing API  error: Unable to contact datalink server');
     }
     $resp = $response->getBody();
     // Log datalink requests;
     $this->getDi()->errorLogTable->log(sprintf("ccBill billing API  debug:\n%s\n%s", $requestString, $resp));
     $xml = simplexml_load_string($resp);
     if ((string) $xml->approved != "1") {
         throw new Am_Exception_InternalError('ccBill Subscription Management error: Incorrect response received while attempting to upgrade subscription!');
     }
     $tr = new Am_Paysystem_Transaction_Ccbill_Upgrade($this, $xml);
     // Add payment to new invocie;
     $newInvoice->addPayment($tr);
     // Cancel old one
     $invoice->setCancelled(true);
 }
예제 #6
0
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $request = $this->createHttpRequest();
     $ps = new stdclass();
     $ps->type = 'cncl';
     $ps->reason = 'ticket.type.cancel.7';
     $ps->comment = 'cancellation request from aMember user (' . $invoice->getLogin() . ')';
     $get_params = http_build_query((array) $ps, '', '&');
     $payment = current($invoice->getPaymentRecords());
     $request->setUrl($s = 'https://api.clickbank.com/rest/1.3/tickets/' . Am_Di::getInstance()->invoicePaymentTable->getLastReceiptId($invoice->pk()) . "?{$get_params}");
     $request->setHeader(array('Content-Length' => '0', 'Accept' => 'application/xml', 'Authorization' => $this->getConfig('dev_key') . ':' . $this->getConfig('clerk_key')));
     $request->setMethod(Am_HttpRequest::METHOD_POST);
     $this->logRequest($request);
     $request->setMethod('POST');
     $response = $request->send();
     $this->logResponse($response);
     if ($response->getStatus() != 200 && $response->getBody() != 'Subscription already canceled') {
         throw new Am_Exception_InputError("An error occurred while cancellation request");
     }
 }