I want to integrate mangopay using php and i am using following link as ref: http://docs.mangopay.com/api-references/wallets/ but i can't able to do that because if i am use any options like create wallet or any other then it will try to create new user even i am trying to use any other option.
following is code which i used for create new wallet in mangopay:
<h2>Create User</h2>
<form action="https://api.sandbox.mangopay.com/v2/clients" method="post">
<input name="ClientId" id="ClientId" value="<cust's sandbox id>" /><br>
<input name="Email" id="Email" value="" /><br>
<input name="FirstName" id="FirstName" value="" /><br>
<input name="LastName" id="LastName" value="" /><br>
<input name="Birthday" id="Birthday" value="<?php echo strtotime("1988-03-19");?>" /><br>
<input name="Nationality" id="Nationality" value="DE" /><br>
<input name="CountryOfResidence" id="CountryOfResidence" value="DE" /><br>
<input type="submit" value="submit">
</form>
<h2>Create Wallet</h2>
<form action="https://api.sandbox.mangopay.com/v2/clients" method="post">
<input name="ClientId" id="ClientId" value="<cust's sandbox id>" /><br>
<input name="Owners" id="Owners" value="<cust's sandbox id>" /><br>
<input name="Email" id="Email " value="mddipen" /><br>
<input name="Description" id="Description" value="" /><br>
<input name="Currency" id="Currency" value="EUR" /><br>
<input type="submit" value="submit">
</form>
define('MANGOPAY_REQUEST_URL','https://api.sandbox.mangopay.com/v2/');
define('MANGOPAY_ADMIN_ID','Admin ID');
define('CURL_AUTH_HEADER','Authentication Key');
function processCurlJsonrequest($parseUrl, $fieldString) { //Initiate cURL request and send back the result
$URL=MANGOPAY_REQUEST_URL.$parseUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic ".CURL_AUTH_HEADER, "Content-Type: application/json; charset=utf-8","Accept:application/json, text/javascript, */*; q=0.01"));
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fieldString));
curl_setopt($ch, CURLOPT_POST, 1);
$resulta = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
return $resulta;
}
$data = array(
"FirstName" => $first_name,
"LastName" => $last_name,
"Address" => "",
"Birthday" => $birthdatestr,
"Nationality" => $nationality,
"CountryOfResidence" => $CountryOfResidence,
"Occupation" => "",
"IncomeRange" => "",
"ProofOfIdentity" => null,
"ProofOfAddress" => null,
//"PersonType" => "NATURAL",
"Email" => $email,
"Tag" => ""
);
$parseUrl=MANGOPAY_ADMIN_ID.'/users/natural';
$response= processCurlJsonrequest($parseUrl, $data);
$arrResponse=json_decode($response);
$mangopay_userId = $arrResponse->Id;
$data_mangopay = array(
"Owners" => array($mangopay_userId),
"Description" => "A very cool wallet",
"Currency" => "EUR",
"Tag" => ""
);
$parseUrl=MANGOPAY_ADMIN_ID.'/wallets';
$response_mangopay= processCurlJsonrequest($parseUrl, $data_mangopay);
$arrResponse_mangopay=json_decode($response_mangopay);
$mangopay_walletId = $arrResponse_mangopay->Id;