예제 #1
0
파일: amex-hpp.php 프로젝트: grlf/eyedock
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = new Am_HttpRequest(sprintf('https://gateway-japa.americanexpress.com/api/rest/version/23/merchant/%s/session', $this->getConfig('merchant')), Am_HttpRequest::METHOD_POST);
     $req->setAuth('merchant.' . $this->getConfig('merchant'), $this->getConfig('password'));
     $req->setBody(Am_Controller::getJson(array('apiOperation' => 'CREATE_PAYMENT_PAGE_SESSION', 'order' => array('id' => $invoice->public_id, 'amount' => $invoice->first_total, 'currency' => $invoice->currency), 'paymentPage' => array('cancelUrl' => $this->getCancelUrl(), 'returnUrl' => $this->getPluginUrl('thanks')))));
     $this->logRequest($req);
     $res = $req->send();
     $this->logResponse($res);
     if ($res->getStatus() != 201) {
         $result->setFailed(sprintf('Incorrect Responce Status From Paysystem [%s]', $res->getStatus()));
         return;
     }
     $msg = Am_Controller::decodeJson($res->getBody());
     if ($msg['result'] == 'ERROR') {
         $result->setFailed($msg['error']['explanation']);
         return;
     }
     $invoice->data()->set(self::DATA_KEY, $msg['successIndicator'])->update();
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->{'merchant'} = $this->getConfig('merchant');
     $a->{'order.description'} = $invoice->getLineDescription();
     $a->{'paymentPage.merchant.name'} = $this->getDi()->config->get('site_title');
     $a->{'session.id'} = $msg['session']['id'];
     $this->logRequest($a);
     $result->setAction($a);
 }
예제 #2
0
 public function setValue($value)
 {
     if (is_string($value)) {
         $value = Am_Controller::decodeJson($value);
     }
     $this->value = (array) $value;
     foreach ($this->value as &$row) {
         if (empty($row['id'])) {
             continue;
         }
         if (isset($row['config']) && is_string($row['config'])) {
             parse_str($row['config'], $c);
             if (get_magic_quotes_gpc()) {
                 $c = Am_Request::ss($c);
             }
             // remove quotes
             $row['config'] = $c;
         }
         if ($brick = $this->getBrick($row['class'], $row['id'])) {
             $brick->setFromRecord($row);
         }
     }
     // handle special case - where there is a "multiple" brick and that is enabled
     // we have to insert additional brick to "disabled", so new bricks of same
     // type can be added in editor
     $disabled = $this->getBricks(self::DISABLED);
     foreach ($this->getBricks(self::ENABLED) as $brick) {
         if (!$brick->isMultiple()) {
             continue;
         }
         $found = false;
         foreach ($disabled as $dBrick) {
             if ($dBrick->getClass() == $brick->getClass()) {
                 $found = true;
                 break;
             }
         }
         // create new disabled brick of same class
         if (!$found) {
             $this->getBrick($brick->getClass(), null);
         }
     }
 }
 function upgradeFlowPlayerKey()
 {
     if (version_compare($this->db_version, '4.2.16') < 0) {
         echo "Update Flowplayer License Key...";
         if (ob_get_level()) {
             ob_end_flush();
         }
         $request = new Am_HttpRequest('https://www.amember.com/fplicense.php', Am_HttpRequest::METHOD_POST);
         $request->addPostParameter('root_url', $this->getDi()->config->get('root_url'));
         try {
             $response = $request->send();
         } catch (Exception $e) {
             echo "request failed " . $e->getMessage() . "\n<br />";
             return;
         }
         if ($response->getStatus() == 200) {
             $body = $response->getBody();
             $res = Am_Controller::decodeJson($body);
             if ($res['status'] == 'OK' && $res['license']) {
                 Am_Config::saveValue('flowplayer_license', $res['license']);
             }
         }
         echo "Done<br>\n";
     }
 }
예제 #4
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']);
 }
예제 #5
0
파일: sliiing.php 프로젝트: grlf/eyedock
 public function getRawValue()
 {
     $value = parent::getRawValue();
     return Am_Controller::decodeJson($value);
 }
예제 #6
0
 protected function parseResponse(HTTP_Request2_Response $response)
 {
     $this->params = Am_Controller::decodeJson($response->getBody());
 }
예제 #7
0
 /** @return bool true on success, false and set internal error code on failure */
 public function validate($response)
 {
     if (!$this->isConfigured()) {
         throw new Am_Exception_Configuration("Brick: ReCaptcha error - recaptcha is not configured. Please go to aMember Cp -> Setup -> ReCaptcha and enter keys");
     }
     $req = new Am_HttpRequest('https://www.google.com/recaptcha/api/siteverify', Am_HttpRequest::METHOD_POST);
     $req->addPostParameter('secret', Am_Di::getInstance()->config->get('recaptcha-private-key'));
     $req->addPostParameter('remoteip', $_SERVER['REMOTE_ADDR']);
     $req->addPostParameter('response', $response);
     $response = $req->send();
     if ($response->getStatus() == '200') {
         $r = Am_Controller::decodeJson($response->getBody());
         return $r['success'];
     }
 }
예제 #8
0
파일: SavedForm.php 프로젝트: grlf/eyedock
 function getFields()
 {
     return (array) Am_Controller::decodeJson($this->fields);
 }
예제 #9
0
 function init()
 {
     $r = Am_Controller::decodeJson($this->request->getRawBody());
     if ($r && isset($r['notification']) && isset($r['iv'])) {
         $msg = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, substr(sha1($this->plugin->getConfig('secret')), 0, 32), base64_decode($r['notification']), MCRYPT_MODE_CBC, base64_decode($r['iv'])), "..");
         $this->notification = Am_Controller::decodeJson($msg);
         $this->plugin->logOther('DECODED NOTIFICATION', $this->notification);
     }
 }