Pesapal.com

Forum

Welcome, Guest
Username
Password:
 

Fatal error: Cannot redeclare class OAuthSignature
(1 viewing) (1) Guest
Welcome to the Pesapal integration forum!

This forum discusses everything about Pesapal integration on your web site. Having any problems? This is the right place to post a question and we are sure you will get an answer
  • Page:
  • 1

TOPIC: Fatal error: Cannot redeclare class OAuthSignature

Fatal error: Cannot redeclare class OAuthSignature 11 years, 1 month ago #1043

  • lazro
  • OFFLINE
  • Administrator
  • Pesapal
  • Posts: 404
Hello,

If you get this error when integrating PesaPal "Fatal error: Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1" it's because the class OAuthSignatureMethod_HMAC_SHA1 has already been defined withing your system (probably by another 3rd party plugin).

To prevent this error from showing up, add a wrapper around the class that brings the error "cannot redeclare...." that check if the class has already been defined, ignoring it's declaration if so. Check the code below on how to do this:


if(!class_exists( $classname ) ) {
// include your class code
}


eg..


if(!class_exists("OAuthSignatureMethod_HMAC_SHA1") ) {
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}

public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;

$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);

$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);

return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
}
Regards,

Lazaro Ong'ele
Web Developer

Skype: Lazrotep
+254-020-249-5438 ; +254-706-191-729
Dagoretti Lane, Off Naivasha Road.

Facebook: www.facebook.com/pesapal
Twitter: twitter.com/PesaPal
Helpdesk: support.pesapal.com
This e-mail address is being protected from spambots. You need JavaScript enabled to view it.
Last Edit: 11 years, 1 month ago by lazro.
  • Page:
  • 1