static function ConstructAccount($authCode)
 {
     //get client secret
     $partner = new Partner(Application::PARTNER_CODE);
     $clientSecret = $partner->getConfigValue(PartnerConfig::STRIPE_CLIENTSECRET);
     //call stripe to get auth tokens
     $request = curl_init('https://connect.stripe.com/oauth/token');
     $request_params = array('client_secret' => $clientSecret, 'grant_type' => 'authorization_code', 'code' => $authCode);
     curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($request, CURLOPT_POST, true);
     curl_setopt($request, CURLOPT_POSTFIELDS, http_build_query($request_params));
     // TODO: Additional error handling
     $respCode = curl_getinfo($request, CURLINFO_HTTP_CODE);
     $response = json_decode(curl_exec($request), true);
     curl_close($request);
     //create stripe account
     $account = new StripeAccount();
     $account->setAccessToken($response['access_token']);
     $account->setRefreshToken($response['refresh_token']);
     $account->setPublishableKey($response['stripe_publishable_key']);
     $account->setUserId($response['stripe_user_id']);
     $account->save();
     //done
     return $account;
 }
 function getContent()
 {
     $partner = new Partner(Application::PARTNER_CODE);
     //compile page array
     $pageValues = array('dictionaryCode' => $this->dictionary->getCode(), 'paymentConfigCode' => $this->provider->getPaymentConfigCode(), 'stripeClientId' => $partner->getConfigValue(PartnerConfig::STRIPE_CLIENTID));
     //done
     return Application::LoadTemplate('stripe-setup.html', $pageValues);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $siteContact = new SiteContact();
         $siteContact->setUserId($user->getId());
         $siteContact->setTypeId(Params::GetLong('typeId'));
         $siteContact->setContactName(Params::Get('contactName'));
         $siteContact->setContactEmailAddress(Params::Get('contactEmailAddress'));
         $siteContact->setContactPhone(Params::Get('contactPhone'));
         $siteContact->setDictionaryCode($dictionary->getCode());
         $siteContact->setContent(Params::Get('content'));
         if ($siteContact->validate()) {
             $siteContact->save();
             $success = true;
             //notify partner by email
             $partner = new Partner(Application::PARTNER_CODE);
             $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
             $content = "\n";
             $content .= "A new site contact has been submitted on treatnow.co.\n\n";
             $content .= '---------------------------------------------------------------------' . "\n";
             $content .= "Type: " . $siteContact->getTypeName() . "\n";
             $content .= "Contact Name: " . $siteContact->getContactName() . "\n";
             $content .= "Contact Email: " . $siteContact->getContactEmailAddress() . "\n";
             $content .= "Contact Phone: " . $siteContact->getContactPhone() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= $siteContact->getContent() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= "You can manage the contact here: http://manage.zidmi.com/operations/contacts/";
             Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Site Contact', $content);
         } else {
             $message = $siteContact->getValidationError();
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $verificationCode = Params::Get('verificationCode');
         $verifierName = Params::Get('verifierName');
         $feedback = Params::Get('feedback');
         if (!is_null($verificationCode) && !is_null($verifierName) && !is_null($feedback)) {
             $provider = Provider::FromVerificationCode($verificationCode);
             if (!is_null($provider)) {
                 //add provider event
                 $reference = 'UserId:' . $user->getId();
                 $notes = "Submitted by:" . $verifierName . "\n" . $feedback;
                 $provider->addEvent(ProviderEventType::VERIFICATION_FEEDBACK, $reference, $notes);
                 $success = true;
                 //notify email
                 $partner = new Partner(Application::PARTNER_CODE);
                 $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
                 $content = "\n";
                 $content .= "Some feedback has been submitted regarding provider data.\n\n";
                 $content .= '---------------------------------------------------------------------' . "\n";
                 $content .= "Provider: " . $provider->getName() . "\n";
                 $content .= "Submitted by: " . $verifierName . "\n";
                 $content .= "Feedback: \n";
                 $content .= $feedback . "\n";
                 $content .= '---------------------------------------------------------------------' . "\n\n";
                 Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Provider Verification Feedback', $content);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }