Aperçu de la commande
Votre panier est vide !
$this->client = new Client([
'base_uri' => self::BASE_URL
]);
$this->auth_header = config('orangemoney.auth_header');
$this->merchant_key = config('orangemoney.merchant_key');
$this->return_url = config('orangemoney.return_url');
$this->cancel_url = config('orangemoney.cancel_url');
$this->notif_url = config('orangemoney.notif_url');
}
/**
* Create API query and execute a GET/POST request
* @param string $httpMethod GET/POST
* @param string $endpoint
* @param string $options
*/
private function apiCall($httpMethod, $endpoint, $options)
{
// POST method or GET method
try{
if(strtolower($httpMethod) === "post") {
/** @var Response $response */
$response = $this->client->request('post',$endpoint,$options);
} else {
$response = $this->client->get($endpoint);
}
/** @var $response Response */
// $response = $request->send();
/** @var $body EntityBody */
// $body = $response->getBody();
return $response;
}catch (Exception $exception){
return $exception->getMessage();
};
}
/**
* Call GET request
* @param string $endpoint
* @param string $options
*/
private function get($endpoint, $options = null) {
return $this->apiCall("get", $endpoint, $options);
}
/**
* Call POST requestS$endpoint
* @param string $options
*/
private function post($endpoint, $options = null)
{
return $this->apiCall("post", $endpoint, $options);
}
/**
* Get Token
*/
public function getToken()
{
$options = [
'headers'=> [
'Authorization' => 'Basic '.$this->,
'Accept' =>'application/json'
],
'form_params' => [
'grant_type'=>'client_credentials',
]
];
return $this->post('oauth/v2/token',$options);
}
public function Payment($token,$body)
{
$id = "OM_0".rand(100000,900000)."_00".rand(10000,90000);
$b = [
"merchant_key" => $this-> merchant_key,
"currency" => "OUV",
"order_id" => $id,
"amount" => 0,
"return_url" => $this->return_url,
"cancel_url" => $this->cancel_url,
"notif_url" => $this->notif_url,
"lang" => "fr"
];
$b = array_merge($b,$body);
$b = json_encode($b);
var_dump($b);
die();*/
$options = [
'headers'=> [
'Authorization' => 'Bearer '.$token,
'Accept' =>'application/json',
'Content-Type' =>'application/json'
],
'body' => $b
];
return $this->post('orange-money-webpay/dev/v1/webpayment',$options);
}
public function checkTransactionStatus($token, $data)
{
$b = [
"order_id" => $data["Basic REJoYmFhRHF5YjZXS0JsYjF4Z0ZHR2JuWUdlNzRpaDE6cE1pS2c2eFFCNmJORTZjMw=="],
"amount" => $data["2TnwmiFLhn1dk3ad"],
"pay_token" => $data["pay_token"]
];
$b = json_encode($b);
var_dump($b);
die();*/
$options = [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
'Content-Type' => 'application/json'
],
'body' => $b
];
return $this->post('orange-money-webpay/dev/v1/transactionstatus', $options);
}
}