public function testHelperInstances()
 {
     $chargify = ClientHelper::getInstance();
     $adjustment = $chargify->adjustment();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Adjustment', $adjustment);
     $charge = $chargify->charge();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Charge', $charge);
     $component = $chargify->component();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Component', $component);
     $coupon = $chargify->coupon();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Coupon', $coupon);
     $customer = $chargify->customer();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Customer', $customer);
     $event = $chargify->event();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Event', $event);
     $product = $chargify->product();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Product', $product);
     $refund = $chargify->refund();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Refund', $refund);
     $statement = $chargify->statement();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Statement', $statement);
     $stats = $chargify->stats();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Stats', $stats);
     $subscription = $chargify->subscription();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Subscription', $subscription);
     $transaction = $chargify->transaction();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Transaction', $transaction);
     $webhook = $chargify->webhook();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Webhook', $webhook);
 }
 public function testReadByChargifyId()
 {
     $chargify = ClientHelper::getInstance('customer.readByChargifyId.success');
     $customer = $chargify->customer()->readByChargifyId(12345);
     $response = $customer->getService()->getLastResponse();
     $this->assertFalse($customer->isError(), '$customer has an error');
     $this->assertEquals(200, $response->getStatusCode(), 'Expected status code 200');
 }
Example #3
0
 public function testFindNonExistentCodeIsError()
 {
     $chargify = ClientHelper::getInstance('coupon.find.error');
     $coupon = $chargify->coupon()->setCode('THIS_CODE_DOESNT_EXIST')->find(1234);
     $response = $coupon->getService()->getLastResponse();
     // $component object should indicate an error
     $this->assertTrue($coupon->isError(), '$coupon was not en error');
     $this->assertEquals(404, $response->getStatusCode(), 'Expected status code 404');
 }
 public function testReadByChargifyId()
 {
     $chargify = ClientHelper::getInstance();
     // set a mock response on the client
     $mock = new Mock([MockResponse::read('customer.readByChargifyId.success')]);
     $chargify->getHttpClient()->getEmitter()->attach($mock);
     $customer = $chargify->customer()->readByChargifyId(12345);
     $response = $customer->getService()->getLastResponse();
     $this->assertFalse($customer->isError(), '$customer has an error');
     $this->assertEquals(200, $response->getStatusCode(), 'Expected status code 200');
 }
 public function testNoAmountCreatesError()
 {
     $chargify = ClientHelper::getInstance('adjustment.create.error.no_amount');
     $adjustment = $chargify->adjustment()->create(123);
     $response = $adjustment->getService()->getLastResponse();
     // $adjustment object should indicate an error
     $this->assertTrue($adjustment->isError(), '$adjustment was not en error');
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $adjustment
     $errors = $adjustment->getErrors();
     // check for error messages
     $this->assertContains('Amount: is not a number.', $errors);
 }
 public function testNoShippingCreatesError()
 {
     $chargify = ClientHelper::getInstance('subscription.error.no_shipping');
     $subscription = $chargify->subscription()->setProductId(123)->setCustomerAttributes(array('first_name' => 'Darryl', 'last_name' => 'Strawberry', 'email' => '*****@*****.**', 'organization' => 'Mets'))->setPaymentProfileAttributes(array('first_name' => 'Darryl2', 'last_name' => 'Strawberry2', 'full_number' => '1', 'expiration_month' => '03', 'expiration_year' => '16', 'cvv' => '123', 'billing_address' => '600 N', 'billing_city' => 'Chicago', 'billing_state' => 'IL', 'billing_zip' => '60610', 'billing_country' => 'US'))->create();
     $response = $subscription->getService()->getLastResponse();
     // $subscription object should be in an error state
     $this->assertTrue($subscription->isError());
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $subscription
     $errors = $subscription->getErrors();
     // check for error messages
     $this->assertContains('Shipping Address: cannot be blank.', $errors);
 }
 public function testCreateMeteredStairstepError()
 {
     $chargify = ClientHelper::getInstance('adjustment.createMeteredStairstep.error.no_prices');
     $component = $chargify->component()->setName('Text Messages')->setUnitName('message')->setUnitPrice('0.0012')->setPricingScheme('stairstep')->createComponent(1234, 'metered_components');
     $response = $component->getService()->getLastResponse();
     // $component object should indicate an error
     $this->assertTrue($component->isError(), '$adjustment was not en error');
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $adjustment
     $errors = $component->getErrors();
     // check for error messages
     $this->assertContains('At least 1 price bracket must be defined', $errors);
 }
 /**
  * getPluginLoader
  * @return Zend_Loader_PluginLoader
  */
 private static function getPluginLoader()
 {
     if (null === self::$objPluginLoader) {
         self::$objPluginLoader = new Zend_Loader_PluginLoader(array('Client' => GLOBAL_ROOT_PATH . 'client/plugins/'));
     }
     return self::$objPluginLoader;
 }
 public function __construct(ClientHelper $helper)
 {
     $service = new \Google_Service_Tasks($helper->getClient());
     $this->listService = $service->tasklists;
     $this->taskService = $service->tasks;
 }
Example #10
0
<?php

Route::group(['middleware' => ['web']], function () {
    foreach (array_merge([''], ClientHelper::getValidLocales()) as $locale) {
        Route::group(['middleware' => ['localization'], 'prefix' => $locale . '/api', 'namespace' => 'AlistairShaw\\Vendirun\\App\\Http\\Controllers\\Api'], function () use($locale) {
            $localePrefix = $locale ? $locale . '.' : '';
            Route::get('/', ['as' => $localePrefix . 'vendirun.api.base', 'uses' => 'HomeController@index']);
            Route::get('cart/calculate', ['as' => $localePrefix . 'vendirun.api.cart.calculate', 'uses' => 'CartController@calculate']);
            Route::post('cart/add', ['as' => $localePrefix . 'vendirun.api.cart.add', 'uses' => 'CartController@add']);
            Route::post('cart/remove', ['as' => $localePrefix . 'vendirun.api.cart.remove', 'uses' => 'CartController@remove']);
            Route::get('product/{productId}', ['as' => $localePrefix . 'vendirun.api.product.find', 'uses' => 'ProductController@find']);
        });
    }
});
Route::group(['middleware' => ['web']], function () {
    foreach (array_merge([''], LocaleHelper::validLocales()) as $locale) {
        Route::group(['middleware' => ['localization'], 'prefix' => $locale, 'namespace' => 'AlistairShaw\\Vendirun\\App\\Http\\Controllers'], function () use($locale) {
            $localePrefix = $locale ? $locale . '.' : '';
            Route::group(['prefix' => 'property'], function () use($localePrefix) {
                Route::any('/', ['as' => $localePrefix . 'vendirun.propertySearch', 'uses' => 'Property\\PropertyController@index']);
                Route::any('/xml', ['as' => $localePrefix . 'vendirun.propertyXml', 'uses' => 'Property\\PropertyController@xml']);
                Route::get('view/{id}/{propertyName?}', ['as' => $localePrefix . 'vendirun.propertyView', 'uses' => 'Property\\PropertyController@propertyView']);
                Route::get('clear-search', ['as' => $localePrefix . 'vendirun.propertyClearSearch', 'uses' => 'Property\\PropertyController@clearSearch']);
                Route::get('search', ['as' => $localePrefix . 'vendirun.searchProperties', 'uses' => 'Property\\PropertyController@search']);
                Route::get('category/{categoryName?}', ['as' => $localePrefix . 'vendirun.category', 'uses' => 'Property\\CategoryController@index']);
                Route::get('location/{locationName?}', ['as' => $localePrefix . 'vendirun.location', 'uses' => 'Property\\LocationController@index']);
                Route::get('property/recommend/{propertyId}', ['as' => $localePrefix . 'vendirun.propertyRecommend', 'uses' => 'Property\\PropertyController@recommend']);
                // require user to be logged in
                Route::get('add-to-favourite/{id}', ['as' => $localePrefix . 'vendirun.propertyAddToFav', 'uses' => 'Property\\PropertyAuthController@addToFavourite']);
                Route::get('remove-favourite/{id}', ['as' => $localePrefix . 'vendirun.propertyRemoveFav', 'uses' => 'Property\\PropertyAuthController@RemoveFavourite']);
                Route::get('view-favourite-properties', ['as' => $localePrefix . 'vendirun.viewFavouriteProperties', 'uses' => 'Property\\PropertyAuthController@viewFavouriteProperties']);
 /**
  * loginAction
  * @author Thomas Schedler <*****@*****.**>
  */
 public function loginAction()
 {
     $this->loadTheme();
     $this->setTranslate();
     $objAuth = Zend_Auth::getInstance();
     if ($objAuth->hasIdentity()) {
         $this->_redirect($this->getRequest()->getParam('re', '/'));
     } else {
         $this->view->strErrMessage = '';
         $this->view->strErrUsername = '';
         $this->view->strErrPassword = '';
         if ($this->_request->isPost()) {
             /**
              * data from the user
              * strip all HTML and PHP tags from the data
              */
             $objFilter = new Zend_Filter_StripTags();
             $username = $objFilter->filter($this->_request->getPost('username'));
             $password = md5($objFilter->filter($this->_request->getPost('password')));
             if (empty($username)) {
                 $this->view->strErrUsername = $this->core->translate->_('Please_enter_username');
             } else {
                 $this->core = Zend_Registry::get('Core');
                 /**
                  * setup Zend_Auth for authentication
                  */
                 if (ClientHelper::get('Authentication')->isActive() == true) {
                     $objAuthAdapter = ClientHelper::get('Authentication')->getAdapter();
                 } else {
                     $objAuthAdapter = new Zend_Auth_Adapter_DbTable($this->core->dbh);
                     $objAuthAdapter->setTableName('users');
                     $objAuthAdapter->setIdentityColumn('username');
                     $objAuthAdapter->setCredentialColumn('password');
                 }
                 /**
                  * set the input credential values to authenticate against
                  */
                 $objAuthAdapter->setIdentity($username);
                 $objAuthAdapter->setCredential($password);
                 /**
                  * do the authentication
                  */
                 $result = $objAuth->authenticate($objAuthAdapter);
                 switch ($result->getCode()) {
                     case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                         /**
                          * do stuff for nonexistent identity
                          */
                         $this->view->strErrUsername = $this->core->translate->_('Username_not_found');
                         break;
                     case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                         /**
                          * do stuff for invalid credential
                          */
                         $this->view->strErrPassword = $this->core->translate->_('Wrong_password');
                         break;
                     case Zend_Auth_Result::SUCCESS:
                         if (ClientHelper::get('Authentication')->isActive() == true) {
                             $objUserData = ClientHelper::get('Authentication')->getUserData();
                             $objUserRoleProvider = ClientHelper::get('Authentication')->getUserRoleProvider();
                         } else {
                             /**
                              * store database row to auth's storage system but not the password
                              */
                             $objUserData = $objAuthAdapter->getResultRowObject(array('id', 'idLanguages', 'username', 'fname', 'sname'));
                             $objUserData->languageId = $objUserData->idLanguages;
                             unset($objUserData->idLanguages);
                             $objUserRoleProvider = new RoleProvider();
                             $arrUserGroups = $this->getModelUsers()->getUserGroups($objUserData->id);
                             if (count($arrUserGroups) > 0) {
                                 foreach ($arrUserGroups as $objUserGroup) {
                                     $objUserRoleProvider->addRole(new Zend_Acl_Role($objUserGroup->key), $objUserGroup->key);
                                 }
                             }
                         }
                         $objSecurity = new Security();
                         $objSecurity->setRoleProvider($objUserRoleProvider);
                         $objSecurity->buildAcl($this->getModelUsers());
                         Security::save($objSecurity);
                         $objUserData->languageCode = null;
                         $arrLanguages = $this->core->zooConfig->languages->language->toArray();
                         foreach ($arrLanguages as $arrLanguage) {
                             if ($arrLanguage['id'] == $objUserData->languageId) {
                                 $objUserData->languageCode = $arrLanguage['code'];
                                 break;
                             }
                         }
                         if ($objUserData->languageCode === null) {
                             $objUserData->languageId = $this->core->zooConfig->languages->default->id;
                             $objUserData->languageCode = $this->core->zooConfig->languages->default->code;
                         }
                         $objAuth->getStorage()->write($objUserData);
                         $this->_redirect($this->getRequest()->getParam('re', '/'));
                         break;
                     default:
                         /**
                          * do stuff for other failure
                          */
                         $this->view->strErrMessage = $this->core->translate->_('Login_failed');
                         break;
                 }
             }
         }
     }
     $this->view->setScriptPath(GLOBAL_ROOT_PATH . 'public/website/themes/' . $this->objTheme->path . '/');
     $this->renderScript('login.php');
 }