curl API return 401 error in Magento 2
I m trying to implement worldpay on a PHP site using XML direct method but whenever I try to connect I get error saying you are not authorized to view the file.. Can you tell me were you testing the payment gateway on live site.
Code:
$adminUrl="https://secure.worldpay.com/sso/public/auth/login.html?serviceIdentifier=merchantadmin";
$data = array("username" => $merchant_user, "password" => $merchant_password);
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token = json_decode($token);
// var_dump($token);
// echo json_encode($token);
$url = 'https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp';
$authorization = "Authorization: Bearer $token";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', $token));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
$result = curl_exec($ch);
// // curl_close($ch);
echo json_encode($result);
How to solve it?
Anyone can help me to solve this
i was used this payment-gateway .
magento2 payment-gateway curl
|
show 11 more comments
I m trying to implement worldpay on a PHP site using XML direct method but whenever I try to connect I get error saying you are not authorized to view the file.. Can you tell me were you testing the payment gateway on live site.
Code:
$adminUrl="https://secure.worldpay.com/sso/public/auth/login.html?serviceIdentifier=merchantadmin";
$data = array("username" => $merchant_user, "password" => $merchant_password);
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token = json_decode($token);
// var_dump($token);
// echo json_encode($token);
$url = 'https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp';
$authorization = "Authorization: Bearer $token";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', $token));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
$result = curl_exec($ch);
// // curl_close($ch);
echo json_encode($result);
How to solve it?
Anyone can help me to solve this
i was used this payment-gateway .
magento2 payment-gateway curl
make sure you are using this api token url/rest/V1/integration/admin/token
– magefms
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago
|
show 11 more comments
I m trying to implement worldpay on a PHP site using XML direct method but whenever I try to connect I get error saying you are not authorized to view the file.. Can you tell me were you testing the payment gateway on live site.
Code:
$adminUrl="https://secure.worldpay.com/sso/public/auth/login.html?serviceIdentifier=merchantadmin";
$data = array("username" => $merchant_user, "password" => $merchant_password);
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token = json_decode($token);
// var_dump($token);
// echo json_encode($token);
$url = 'https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp';
$authorization = "Authorization: Bearer $token";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', $token));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
$result = curl_exec($ch);
// // curl_close($ch);
echo json_encode($result);
How to solve it?
Anyone can help me to solve this
i was used this payment-gateway .
magento2 payment-gateway curl
I m trying to implement worldpay on a PHP site using XML direct method but whenever I try to connect I get error saying you are not authorized to view the file.. Can you tell me were you testing the payment gateway on live site.
Code:
$adminUrl="https://secure.worldpay.com/sso/public/auth/login.html?serviceIdentifier=merchantadmin";
$data = array("username" => $merchant_user, "password" => $merchant_password);
$data_string = json_encode($data);
$ch = curl_init($adminUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$token = curl_exec($ch);
$token = json_decode($token);
// var_dump($token);
// echo json_encode($token);
$url = 'https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp';
$authorization = "Authorization: Bearer $token";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', $token));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml );
$result = curl_exec($ch);
// // curl_close($ch);
echo json_encode($result);
How to solve it?
Anyone can help me to solve this
i was used this payment-gateway .
magento2 payment-gateway curl
magento2 payment-gateway curl
edited 17 mins ago
divya sekar
asked yesterday
divya sekardivya sekar
13012
13012
make sure you are using this api token url/rest/V1/integration/admin/token
– magefms
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago
|
show 11 more comments
make sure you are using this api token url/rest/V1/integration/admin/token
– magefms
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago
make sure you are using this api token url
/rest/V1/integration/admin/token
– magefms
yesterday
make sure you are using this api token url
/rest/V1/integration/admin/token
– magefms
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago
|
show 11 more comments
2 Answers
2
active
oldest
votes
- This is the Data
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
}
add a comment |
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f261724%2fcurl-api-return-401-error-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
- This is the Data
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
}
add a comment |
- This is the Data
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
}
add a comment |
- This is the Data
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
}
- This is the Data
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
}
edited 17 hours ago
magefms
896220
896220
answered 18 hours ago
Umarfarooq GalibwaleUmarfarooq Galibwale
715
715
add a comment |
add a comment |
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
add a comment |
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
add a comment |
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
dataFormat = array('temp_order_id'=>$qouteId, 'MobileNumber'=>$mobileNo, 'OTP'=>$otp, 'Amount'=>$amount); $response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here I'm calling Helper function
$response = $helper->getcurlDataArray($dataFormat,"username" => $merchant_user,"password" => $merchant_password, $adminUrl);
- Here is the Helper function
public function getcurlDataArray($dataFormat,$username,$password,$service_url){
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataFormat));
curl_setopt($ch, CURLOPT_USERPWD, $username. ":" .$password);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$token = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
$Errorhead = 'CurlError for Url:'.$service_url.' DataFormat:'.json_encode($dataFormat);
$this->logError($Errorhead,$error_msg);
}
$response = json_decode($token,true);
return $response;
edited 18 hours ago
magefms
896220
896220
answered 19 hours ago
Umarfarooq GalibwaleUmarfarooq Galibwale
715
715
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
add a comment |
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
@divya sekar, Please check this code might be it will be helpful for u
– Umarfarooq Galibwale
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
i will tried and update u @Umar
– divya sekar
18 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
no i was getting a null value @umar
– divya sekar
2 hours ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f261724%2fcurl-api-return-401-error-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
make sure you are using this api token url
/rest/V1/integration/admin/token
– magefms
yesterday
I used my payment gateway administration Interface url
– divya sekar
yesterday
try this one $adminUrl = "127.0.0.1/your_Magento_dir/rest/V1/integration/admin/token"
– magefms
23 hours ago
assuming you are running on localhost 127.0.0.1
– magefms
23 hours ago
modify your $adminUrl value like that one
– magefms
23 hours ago