asterisk2billing.org
http://forum.asterisk2billing.org/

Account Creation
http://forum.asterisk2billing.org/viewtopic.php?f=18&t=4642
Page 1 of 1

Author:  jroscow [ Wed Dec 10, 2008 10:46 am ]
Post subject:  Account Creation

hey,

I was wondern what function to call to create an account from an external source?

I don't want to just insert into cc_card, because I am not sure that will work well. I see perform_add in the form class include, but it requires being from form data, and I am not sure how to manipulate that.

any advice would be great, thanks!

reg,
/John

Author:  jroper [ Wed Dec 10, 2008 2:35 pm ]
Post subject: 

The API used for ECommerce may give you a solution. I think there are some help docs in the Docs directory in the tarball


Joe

Author:  jroscow [ Wed Dec 10, 2008 5:13 pm ]
Post subject: 

Thanks Joe, I will check that out.

Added after 1 hours 54 minutes:

That ended up working. You rock!

Author:  jroper [ Wed Dec 10, 2008 6:28 pm ]
Post subject: 

Quick work !

For the benefit of all, because we have not had too many posts on the ecommerce API, would you mind giving us an overview of what you did and how.

Yours

Joe

Author:  jroscow [ Wed Dec 10, 2008 6:56 pm ]
Post subject: 

Yes, and I will actually contribute back the code.

The thing that gave me the most problem was the fact that you _had_ to have a "product" (which is really just a template for new users), and I could not create this from the web interface so I had to insert one directly into the db.

After that, it was just a post request, no changes to the actual file :)

-John

Author:  newton [ Tue Jan 06, 2009 8:52 pm ]
Post subject: 

any chance to get a link to that API? Or can you tell me where I can find it. Thanks all.

edit:
Ok, nevermind so I found the file that you all were talking about...
A2Billing_UI/api/api_ecommerce.php

However I still need some advice. How did you create the 'product'? In what table did you put it in the database? Please advise. thanks.

Added after 52 minutes:

OK, so after investigating a bit more I was able to add an ecommerce product, but I still cannot use the api_ecommerce.php script to provision a user.

When I try to execute for example:
http://xxxxx.net/A2Billing_UI/api/api_e ... xxxxxx.com

I get the following messages in my apache error log file....
PHP Notice: Undefined variable: createfriend in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: address in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: city in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: state in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: country in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: country in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: zipcode in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: phone in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48
PHP Notice: Undefined variable: fax in /var/www/html/A2Billing_UI/api/api_ecommerce.php on line 48

Why would those variables be undefined? Do I need to include some php library in api_ecommerce.php? Can someone please advise me?

by the way my php version is...
php -version
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

Author:  stavros [ Tue Jan 06, 2009 8:58 pm ]
Post subject: 

As stated earlier in the thread, you must use a POST request rather than a GET request.

Author:  newton [ Tue Jan 06, 2009 9:36 pm ]
Post subject: 

thanks for responding stavros.
However, no matter what I do I still get those errors.

For example I am attempting to use a POST request as follows. In a linux command prompt I execute...
wget http://xxxxx.net/A2Billing_UI/api/api_ecommerce.php --post-data='key=2525259871354&productid=1&forceid=&lastname=EtienneTest&firstname=NewtonTest&[email protected]'

If this is not an appropriate way of testing a POST request, can you please recommend one. Thanks.

Also, Perhaps there is something wrong with my api_ecommerce.php file.
This is line 48 of that file

$list_params = "productid=$productid [createfriend=$createfriend;forceid=$forceid;lastname=$lastname;firstname=$firstname;address=$address;city=$city;state=$state;country=$country;country=$country;zipcode=$zipcode;phone=$phone;email=$email;fax=$fax";

I have also attached it as an attachment if anyone cares to take a look. Perhaps there is an updated version of this file.

Attachments:
File comment: ive renamed the file from .php into .txt so it could be uploaded. is this the latest version of this file?
api_ecommerce.txt [11.71 KiB]
Downloaded 454 times

Author:  stavros [ Tue Jan 06, 2009 10:00 pm ]
Post subject: 

newton wrote:
In a linux command prompt I execute...
Looks good, except you're not providing all the necessary fields. Populate all the fields it's complaining about (ie createfriend, address, etc) and try again.
Quote:
I have also attached it as an attachment if anyone cares to take a look. Perhaps there is an updated version of this file.
You could have consulted the revision log for that file.

Author:  gabosdenes [ Tue Feb 03, 2009 5:56 pm ]
Post subject: 

What are the required parameters for the api? What's the productid? I can't find the documentation anywhere.

Thanks,
Deni

Author:  newton [ Tue Feb 03, 2009 6:58 pm ]
Post subject: 

The parameters are:
@key text 40 long
@productid int
@forceid bigint ()
@lastname text 40 long
@firstname text 40 long
@address text 100 long
@city text 40 long
@state text 40 long
@country text 40 long
@zipcode text 40 long
@phone text 40 long
@email text 60 long
@fax text 40 long

The script can be found at: /var/www/html/A2Billing_UI/api/api_ecommerce.php
(adjust according to your installation)

productid is the id of the e-product you created. you can create a e-product once you log into the Admin interface of A2Billing and in the navigation menu under "Billing->Add-Eproduct"

hope this helps

Author:  gabosdenes [ Tue Feb 03, 2009 9:57 pm ]
Post subject: 

I created a product like you said newton and that products id is 1.
I call the api like this:
api/api_ecommerce.php?key=2cebacca69a0c73c3a81d74436c7c647&productid=1&forceid=&lastname=Lastnameee&firstname=Firstnameee&address=Adressss&city=Cityyy&state=Stateee&country=Countryyy&zipcode=123456&phone=1234567890&[email protected]&fax=1234567890
where key is the md5 of the api_security_key in a2billing.conf
I get 400 Bad Request

In /tmp/api_ecommerce_request.log I get [03/02/2009 22]:[[productid=1] CODE_ERROR 1]

What's the forceid parameter?

Deni

Added after 35 minutes:

I tryed posting the data from the command line:
wget http://www.somedomain.com/adm/api/api_ecommerce.php --post-data='key=obscured&productid=1&forceid=&lastname=EtienneTest&firstname=NewtonTest&[email protected]'

I get: HTTP request sent, awaiting response... 403 Forbidden
22:53:42 ERROR 403: Forbidden.

Added after 36 minutes:

Ok, I solved this error : 22:53:42 ERROR 403: Forbidden.
I had a .htaccess file

Now I get the same error as when submitting the data with GET
400 Bad Request

Added after 23 minutes:

I figured it out, I think there is a bug parsing the config file.
I have this in a2billing.conf: api_ip_auth = 127.0.0.1;12.12.12.12 .. where 12.12.12.12 is my real ip address

If I put just api_ip_auth = 12.12.12.12 it works, although before I have separated the ip list with a ; just like the comment says

Thanks again newton, couldn't have done it without you. I noticed the passwords are generated from letters and numbers unlike with the default sign-up page where the password consists of numbers only. You don't know by any chance if I can set the password with the post data?

Deni

Author:  newton [ Tue Feb 03, 2009 9:58 pm ]
Post subject: 

make sure you use all the parameters, even if you leave them blank.

Also, it seems to want the parameters specified in order.

for example...
wget http://company.org/A2Billing_UI/api/api_ecommerce.php --post-data='key=xxxxxxxxxx&productid=1&createfriend=&forceid=&lastname=EtienneTest2&firstname=NewtonTest2&address=&city=&state=&country=&country=&zipcode=&phone=&[email protected]&fax='

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/