コード例 #1
0
 /**
  * Return the API uri.
  *
  * @return string
  */
 private static function getApiEndPoint()
 {
     if (null === self::$apiEndPoint) {
         self::$apiEndPoint = 'https://' . (self::isTestMode() ? 'sandbox-' : '') . 'api.everypay.gr';
     }
     return self::$apiEndPoint;
 }
コード例 #2
0
 public function process()
 {
     $this->load->model('checkout/order');
     include_once DIR_APPLICATION . '../system/library/Everypay.php';
     $everyPay = new Everypay();
     if ($this->config->get('everypay_mode') === 'live') {
         $everyPay->init($this->config->get('everypay_api_username'), $this->config->get('everypay_api_secret'));
     } else {
         $everyPay->init($this->config->get('everypay_test_api_username'), $this->config->get('everypay_test_api_secret'));
     }
     $response = $this->request->post;
     unset($response['utf8'], $response['_method'], $response['authenticity_token']);
     $status = '';
     //if opencart has automatically escaped the json, unescape it for HMAC validation.
     if (isset($response['processing_warnings'])) {
         $response['processing_warnings'] = html_entity_decode($response['processing_warnings']);
     }
     if (isset($response['processing_errors'])) {
         $response['processing_errors'] = html_entity_decode($response['processing_errors']);
     }
     foreach ($response as $key => $value) {
         $status .= "\n{$key} => {$value}";
     }
     $status = $everyPay->verify($response);
     switch ($status) {
         case 1:
             $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], $this->config->get('everypay_order_status_id'), '', true);
             $this->response->redirect($this->url->link('checkout/success'));
             break;
         case 2:
             $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], 7, '', true);
             $this->response->redirect($this->url->link('checkout/checkout'));
             break;
         case 3:
             $this->model_checkout_order->addOrderHistory($this->request->post['order_reference'], 10, '', true);
             $this->response->redirect($this->url->link('checkout/failure'));
             break;
         default:
             $this->response->redirect($this->url->link('checkout/checkout'));
     }
 }
コード例 #3
0
 /**
  * @expectedException         Everypay\Exception\RuntimeException
  * @expectedExceptionMessage  You must set first an API key.
  * @group   ecommerce
  * @group   3dsecure
  */
 public function testThrowExceptionForApiKeys()
 {
     Everypay::reset();
     $key = Everypay::getApiKey();
 }
コード例 #4
0
 public function setUp()
 {
     $credentials = $this->getFixtures()->offsetGet('everypay');
     Everypay::setApiKey($credentials['secret_key_tokenization']);
 }
コード例 #5
0
ファイル: PaymentTest.php プロジェクト: everypay/everypay-php
 public function setUp()
 {
     $credentials = $this->getFixtures()->offsetGet('everypay');
     Everypay::setApiKey($credentials['secret_key']);
     Everypay::$isTest = true;
 }
 /**
  * Refund
  *
  * @param type $order_id
  * @param type $amount
  * @param type $reason
  * @return boolean
  */
 public function process_refund($order_id, $amount = NULL, $reason = '')
 {
     if (!$amount) {
         return false;
     }
     try {
         $params = array('amount' => preg_replace("/[^0-9]/", '', number_format($amount, 2)), 'description' => $reason);
         $token = get_post_meta($order_id, 'token', true);
         Everypay::setApiKey($this->everypaySecretKey);
         $refund = Everypay::refundPayment($token, $params);
         if (!isset($refund['body']['error'])) {
             $dt = new DateTime("Now");
             $timestamp = $dt->format('Y-m-d H:i:s e');
             $refToken = $refund['body']['token'];
             $wc_order = new WC_Order($order_id);
             $wc_order->add_order_note(__('Everypay Refund completed at-' . $timestamp . '-with Refund Token=' . $refToken, 'woocommerce'));
             return true;
         } else {
             return false;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #7
0
 public function setUp()
 {
     $credentials = $this->getFixtures()->offsetGet('everypay');
     Everypay::setApiKey($credentials['secret_key_tokenization']);
     Customer::setClientOption(Http\Client\CurlClient::SSL_VERIFY_PEER, 0);
 }