Quantcast
Viewing all articles
Browse latest Browse all 3

Creating a new account and site

To create a new account and site involves capturing the necessary data and making a few API calls.

  • PUT accounts/single
  • Receive response, and redirect to hosted payment page
  • Return from hosted payment page
  • PUT account_subscriptions/single

Inline Form Validation

Within your form you may wish to validate input via ajax on a :blur event or similar, or prior to form submission.

Validate the email

https://api.pagely.com/v1/accounts/validate?email=some@email.com

Validate the domain name

https://api.pagely.com/v1/domains/validate?domain=domain.com

If a positive response on both, submit the form.

1 Capture and send the account data

function _send_account_data() {

	$form = $this->_get_pp_session('acc_form_post');
	foreach ($form as $k => $v) {
		$form[$k] = trim($v);
	}
	// lets add their plan choice to the session
	$this->_set_pp_session( array('plan_id' => $form['plan']) );

	// never trust user input, rebuild the post array before sending.
	$params['name']			= $form['first_name'] .' '. $form['last_name'];
	$params['username']		= $form['email'];
	$params['company_name']	        = $form['company_name'];
	$params['email']		= $form['email'];
	$params['phone']		= $form['mobile'];
	$params['twitter']		= $form['twitter'];
	$params['affiliate_code'] 	= '';	
	$params['auth_q'] 		= $form['squestion'];	
	$params['auth_q_answer']	= $form['sanswer'];	

	$uri = '/accounts/single';
	$json = $this->_pagely_api_request($method = 'PUT',$uri, $params );

        if ($result->result == 2) {
                // account created do something with it 
        } else {
                // account failed, do something with the error
        } 

        return $result;
}

Full example needed.

The post Creating a new account and site appeared first on Pagely Partner API Docs.


Viewing all articles
Browse latest Browse all 3

Trending Articles