Re: UNAUTHORIZED USER 401

Solved! Go to solution
rnod
Regular Visitor

UNAUTHORIZED USER 401

Dont understand what wrong. https://prnt.sc/rz7vhw headers that i send . I am trying to post simple cybersource payment

https://sandbox.api.visa.com/
$baseUrl
= "cybersource/";
$resourcePath = "v2/payments";
$queryString = "apikey=".$make_pay->conf ['VDP'] ['apiKey'];
$time = time();
$preHashString = $time.$resource_path.$query_string.$requestBodyString;
$xPayToken = "xv2:".$time.":".hash_hmac('sha256', $preHashString, $sharedSecret);
$headers = (array("x-pay-token: ".$xPayToken, "ex-correlation-id: ".$this->getCorrelationId()));
private function getCorrelationId() {
$seed = str_split('abcdefghijklmnopqrstuvwxyz'
.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
.'0123456789');
shuffle($seed);
$rand = '';
foreach (array_rand($seed, 12) as $k) $rand .= $seed[$k];
return $rand."_SC";
}

 

5 REPLIES 5
API_Products
Visa Developer Support Specialist

Re: UNAUTHORIZED USER 401

Hey @rnod,


Currently, the only method to properly query the CyberSource Payments sandbox is creating a merchant account directly with CyberSource:
 
https://developer.cybersource.com 

 

Luckily, their site also provides an easy to use method to test their account credentials:
 
https://developer.cybersource.com/api/reference/api-reference.html 
 
Additionally, here are the following links for sample code:  https://github.com/CyberSource/cybersource-rest-samples-java/blob/master/src/main/java/samples/payme... 

 

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

rnod
Regular Visitor

Re: UNAUTHORIZED USER 401

https://prnt.sc/rzfwo5 i tried to send request from their site and whatever get 401. Tried to register on their site directly and i have error, that i have there account. Maybe i have problem with my credentials?

API_Products
Visa Developer Support Specialist

Re: UNAUTHORIZED USER 401

Hey @rnod,

 

Please reach out to the CyberSource team directly using the phone number below and someone will gladly assist you.

 

CyberSource Support
800-709-7779

 

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

rnod
Regular Visitor

Re: UNAUTHORIZED USER 401

Problem was in my credentials and my code lil bit was outdated. I took credentials from here https://github.com/CyberSource/cybersource-rest-samples-php/blob/master/Samples/Authentication/Stand... and modified my code, from here. Very good example

API_Products
Visa Developer Support Specialist

Re: UNAUTHORIZED USER 401

Hey @rnod,

 

Just wondering, what specific file is outdated? What part of the code was outdated and what part of the code did you modify to get it to work? Thanks 🙂

 

 

 

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.