$authType = "app/user";
$api = Instamojo\Instamojo::init($authType,[
"client_id" => 'XXXXXQAZ',
"client_secret" => 'XXXXQWE',
],true);
try {
$response = $api->createPaymentRequest(array(
"purpose" => "FIFA 16",
"amount" => $_POST["amount"],
"buyer_name" => $_POST["name"],
"send_email" => true,
"email" => $_POST["email"],
"phone" => $_POST["phone"],
"redirect_url" =>"http://localhost/instamojo/payment- success.php"
));
var_dump($response);
}
catch (Exception $e) {
print('Error: ' . $e->getMessage());
};
我正在尝试将 instamojo 集成到我的项目中以进行交易,但出现此错误。 尝试了很多但未能解决这个问题。非常感谢您的帮助。预先感谢。
我更新了作曲家,并从
throw new InvalidRequestException
中删除了 final class Instamojo
,问题仍然存在。
这是通过 Composer 下载 instamojo 时导致此文件出现问题的部分原因
private static function validateTypeParams($type, $params)
{
if (!in_array(strtolower($type), Instamojo::VALID_TYPES)) {
throw new InvalidRequestException('Invalid init type');
}
if (empty($params['client_id'])) {
throw new MissingParameterException('Client Id is missing');
}
if (empty($params['client_secret'])) {
throw new MissingParameterException('Client Secret is missing');
}
if (strtolower($type) == 'user') {
if (empty($params['username'])) {
throw new MissingParameterException('Username is missing');
}
if (empty($params['password'])) {
throw new MissingParameterException('Password is missing');
}
}
};
更改 InvalidRequestException 类的代码
<?php
namespace Instamojo\Exception;
use Exception;
class InstamojoException extends Exception {
private $httpErrorCode;
private $errorNumber;
private $errorMessage;
public function __construct($httpErrorCode, $errorNumber, $errorMessage) {
parent::__construct ($errorMessage);
$this->httpErrorCode = $httpErrorCode;
$this->errorNumber = $errorNumber;
$this->errorMessage = $errorMessage;
}
public function getHttpErrorCode() {
return $this->httpErrorCode;
}
public function getErrorNumber() {
return $this->errorNumber;
}
public function getErrorMessage() {
return $this->errorMessage;
}
}
class InvalidRequestException extends InstamojoException {
public function __construct($errorMessage) {
parent::__construct (null, null, $errorMessage);
}
}