PDA

View Full Version : Account opening API / PHP



zaid_86
06-25-2013, 01:24 PM
Hello,
I am integrating to integrate the vertex API to open real account in PHP,
here is part of my code:



$ret_client = $api_obj->CreateClient($parent_username, $first_name, $second_name, $third_name, $last_name, $username, $password, $phone, $fax, $mobile, $tel_pass, $pob,$country, $email, $address, $show_as_demo, $read_only);

if($ret_client == self::CREATE_CLIENT_SUCCESSFULL){ //successfull, works

$account_id = (int)$account_id; //input from the user
$account_type = 1;
$init_margin = 100.00; //margin is double
$is_DemoAccount = false;
$is_LockedAccount = false;
$DontLiquidate = false;

$ret = $api_obj->CreateAccount($username, $account_id, $account_type, $init_margin, $is_DemoAccount, $is_LockedAccount, $DontLiquidate);

if($ret==self::CREATE_ACCOUNT_RESULT_SUCCESS){
return array('success'=>true, 'login'=>$account_id, 'password'=>$password);
}else{
return array('success'=>false, 'error_reason'=>self::$create_account_results_arr[$ret]);
}
}else{
return array('success'=>false, 'error_reason'=>self::$create_client_results_arr[$ret_client]);
}
as shown in the code, I am trying to do the following:

1- create client using


$ret_client = $api_obj->CreateClient($parent_username, $first_name, $second_name, $third_name, $last_name, $username, $password, $phone, $fax, $mobile, $tel_pass, $pob,$country, $email, $address, $show_as_demo, $read_only);
and it returns "3" which is successfull code as I read in the API

2- create account with the same username and account Id (account id will be entered by the website admin), in the following:


$ret = $api_obj->CreateAccount($username, $account_id, $account_type, $init_margin, $is_DemoAccount, $is_LockedAccount, $DontLiquidate);
but this call returns error code "3" which is 'No previlidges to create Account'

I tried creating client and account using the backoffice software via the same credentials and it worked successfully,

can anyone please help me why this happens?
also I checked the backoffice software and none of the client or account has been created

SVRMGR
06-26-2013, 02:08 PM
are you sure you are using the BAKCOFFICE username and its password that you have received them within the ISV email delivery not a client username and PWD?

SVRMGR
06-26-2013, 02:10 PM
If you are using Backoffice username type it here in order to check its privileges please.

Hassan-HS
06-26-2013, 02:53 PM
Dear Zaid,



In VertexFX ,We have two steps of validation.

1- Local validation:

Which ensure some internal conditions and standards, Then sends request to the server side.
If the result is successful that mean your request sent to the server.

2- Server Validation:

Which ensure the rest of internal conditions and standards, Then sends the result of request to the client side using an event.


------------------------------------------------------------------------


Samples:

When you send login request using "Login()" sub procedure you must wait the event, That will tell you the result of your request.



Public WithEvents m_oBOAPI As CVertexFXBOAPI
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
m_oBOAPI.SetLoginInfo(Zaid, ZaidPW,IP, Val(Port))
m_oBOAPI.Login()
End Sub




In login case you must wait AllDataAreLoaded (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2083) event, That tell me the API loads all data after calling the login method .



Private Sub m_oBOAPI_AllDataAreLoaded() Handles m_oBOAPI.AllDataAreLoaded
MsgBox("All Data Are Loaded")
End Sub


OR InvalidUsernamePassword (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2085)




Private Sub m_oBOAPI_InvalidUsernamePassword() Handles m_oBOAPI.InvalidUsernamePassword
MsgBox("Invalid User Name Password")
End Sub



------------------------------------
In your case:

CreatClient (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2081)function returns to you the result of local validation( If your request sent to the server or not).





Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim transtag As String = TxtUsername.Text
m_oBOAPI.CreateClient(TxtParentUsrname.Text, TxtFName.Text, TxtSecName.Text, TxtThirdName.Text, TxtFamilyName.Text, TxtUsername.Text, TxtPassword.Text, Val(TxtPhone.Text), TxtFax.Text, Val(TxtMobile.Text), TxtTelPwd.Text, TxtPOB.Text, TxtCountry.Text, TxtEmail.Text, TxtAddress.Text, chkShwDemoClient.Checked, chkReadOnly.Checked, transtag)
End Sub




You must wait the server result using this event :

Create Client Result (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2111)




Private Sub m_oBOAPI_CreateClientResult(ByRef Result As VertexFXBOAPI10.CreateClientResultEnum, ByRef tag As String) Handles m_oBOAPI.CreateClientResult
If (Result = CreateClientResultEnum.SuccessfulClientResult) Then
MsgBox("Successful Result")
Else
MsgBox("Unsuccessful Result")
End If
End Sub






Note:

Make sure that AllDataAreLoaded event was invoked -To load all dealer privilege- before use any method except " Login(),SetLoginInfo() "

zaid_86
06-27-2013, 10:08 AM
Hello SVRMGR,


If you are using Backoffice username type it here in order to check its privileges please.

here is the credentials upon your request:


$api_obj = new \COM("VertexFXBOAPI10.CVertexFXBOAPI");
$username = 'amro';
$password = '1212';
$server_ip = "184.173.64.45";
$port = 4401;

zaid_86
06-27-2013, 10:17 AM
Hello SVRMGR,


are you sure you are using the BAKCOFFICE username and its password that you have received them within the ISV email delivery not a client username and PWD?

please find the credentials I am using



$api_obj = new \COM("VertexFXBOAPI10.CVertexFXBOAPI");
$username = 'amro';
$password = '1212';
$server_ip = "184.173.64.45";
$port = 4401;

SVRMGR
06-27-2013, 11:03 AM
Dear Zaid

Please contact your dealing room and ask them to give you enough privileges. You do not have "Create Account" privilege at your account.. ask for also "create client" and see what other privs you need and request them please :)

SVRMGR
06-27-2013, 11:06 AM
You can also register at our ISV partnership program as third party developer and you will get full demo back office with enough privileges for testing purposes, you can use the sent UN and PWD and our own DEMO testing server and port.. if you are interested use this link http://www.hybrid-solutions.com/sales/partnership/isv-program.html :)

zaid_86
06-27-2013, 01:01 PM
Thank you very much SVRMGR,
I will ask for more privileges from the trading room

and I have registered for full demo backoffice through the link provided :)

Hassan-HS
06-28-2013, 12:32 PM
Dear Zaid,

Do you still facing problems and difficulties?

zaid_86
07-01-2013, 07:05 AM
Hello h.abukrayem,


Do you still facing problems and difficulties?

the problem was that I don't check AllDataAreLoaded event in php,

I am still trying to get a way to catch the COM events in PHP,

I will post any update..


Thanks

zaid_86
07-02-2013, 07:20 AM
Hello,
Now I have a problem that the events are not being fired in PHP,

so I have wrote vb.net code just to test the event, but its not being fired also in vb.net code



Imports VertexFXBOAPI10


Public Class Form1
Public WithEvents m_oBOAPI As CVertexFXBOAPI = New CVertexFXBOAPI
Private signed_in As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim username As String
Dim password As String
Dim server_ip As String
Dim server_port As Integer

username = "XXXX"
password = "XXXXXX"
server_ip = "184.173.64.45"
server_port = 4401


m_oBOAPI.SetLoginInfo(username, password, server_ip, Val(server_port))
m_oBOAPI.Login()

Label1.Text = "Logging in..."
End Sub

Private Sub m_oBOAPI_AllDataAreLoaded() Handles m_oBOAPI.AllDataAreLoaded
MsgBox("All Data Are Loaded")
signed_in = True

End Sub

Private Sub m_oBOAPI_InvalidUsernamePassword() Handles m_oBOAPI.InvalidUsernamePassword
MsgBox("Invalid User Name Password")
signed_in = False
End Sub

End Class

in the code login() method is called in the api, and label text is changed accordingly
but no event is triggered after that...

can you check what is wrong with my code?


thanks

Hassan-HS
07-02-2013, 08:32 AM
Dear Zaid,


Are you sure that the IP address is correct?
Are you register DLLs in System32 ?
What is your operating system?

Any way,Your code is under testing now, I will update you soon, Please standby

zaid_86
07-02-2013, 08:48 AM
Hello h.abukrayem,
here is the information you requested



Are you sure that the IP address is correct?


yes, I have verified the IP address and its correct one, since LogedOn attribute value changes if I checked after a while, but the event is not fired..



Are you register DLLs in System32 ?

yes I did,
I have registered VertexFXClientAPI10.0.8.dll and VertexFXBOAPI10.0.10.dll
is there any other DLL I should register?



What is your operating system?

Windows Server 2008 R2 Standard

Hassan-HS
07-02-2013, 09:52 AM
Required BOAPI DLLs :


VertexTradingBOAPI10.0.10.dll
VertexFXBOAPI10.0.10.dll
HSClientBOAPI10.0.10.dll
HSGeneralDLLBOAPI10.0.10.dll

Please disable : Data Execution Prevention (DEP), Please read this article (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3540)

zaid_86
07-02-2013, 10:03 AM
Hello h.abukrayem,

I have registered the remaining DLLs and turned off the DEP, but the problem has not been solved...

Hassan-HS
07-02-2013, 01:20 PM
Dear Zaid,

Your sample is working well on my PC, Can you give me Team-viewer to check the problem together ?

zaid_86
07-02-2013, 01:26 PM
ID: 954 723 768
Password: 1680

Hassan-HS
07-02-2013, 02:25 PM
Dear
Any updates after ran turn off DEP patch as administrator?

zaid_86
07-02-2013, 02:34 PM
Hello,
thanks alot, the event is received after running the batch as administrator

I will try to create client now, and wait for its event..


Regards

Hassan-HS
07-02-2013, 02:39 PM
Good Luck and Thanks for contacting us.

Feel free to let us know if you need any further assistance.

Regards

zaid_86
07-02-2013, 03:06 PM
hello again :)

I am trying to create client as the following:


Dim parent_account As String = "3000000"
Dim first_name As String = "test1"
Dim second_name As String = "test1"
Dim third_name As String = "test1"
Dim last_name As String = "test1"
Dim username As String = "3000001"
Dim password As String = "ADS#2WQ"
Dim phone As Double = 23432432423
Dim fax As String = "233242341"
Dim mobile As Double = 23423543345
Dim tel_pass As String = "araew234"
Dim pob As String = "11118"
Dim country As String = "jordan"
Dim email As String = "test1_api@wewebit.com"
Dim address As String = "Amman...address"
Dim show_as_demo As Boolean = False
Dim read_only As Boolean = False


Dim res As CreateClientResultEnum = m_oBOAPI.CreateClient(parent_account, first_name, second_name, third_name, last_name, username, password, phone, fax, mobile, tel_pass, pob, country, email, address, show_as_demo, read_only)
Label1.Text = "creating client Result: " + res.ToString

but I am receiving NotValidParentClientResult, although I have a client named "3000000"
(you can see the attachment)


can you tell me whats wrong?

Hassan-HS
07-02-2013, 04:22 PM
Dear zaid,

parent name mean the username of group or office where you want to create client in.



Please read this article
(http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2081)

Hassan-HS
07-03-2013, 08:53 AM
Dear Zaid,

Are things are going well?

zaid_86
07-13-2013, 11:37 AM
Hello h.abukrayem,
Sorry for the late reply..

thank you for help! things are now working well...
I ended up writing windows application to handle requests passed from PHP through XML file, this is the best approach I found in order to get things working, and now everything working good..

Hassan-HS
07-13-2013, 12:00 PM
Great !
Please do not hesitate to contact me if you have any further questions.