· 7 years ago · Jun 18, 2018, 11:36 AM
1<?php
2// integration creditinails
3$api_name = "";
4$secret_key = "";
5$password = "";
6// callback notification url
7$notificationURL = "";
8
9// status which you want to test
10$status = 'completed';
11$url = "https://www.alfacoins.com/api/create.json";
12
13$request = [
14 'name' => $api_name,
15 'secret_key' => $secret_key,
16 'password' => strtoupper(md5($password)),
17 'type' => 'bitcoin',
18 'amount' => 100,
19 'order_id' => 1234,
20 'currency' => 'USD',
21 'description' => 'No description',
22 'options' => [
23 'notificationURL' => $notificationURL,
24 'redirectURL' => 'https://google.com/',
25 'payerName' => 'any user',
26 'payerEmail' => 'any@mail.com',
27 'test' => 1,
28 'status' => $status
29 ]
30];
31
32$content = json_encode($request);
33
34$curl = curl_init($url);
35curl_setopt($curl, CURLOPT_HEADER, false);
36curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
37curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json; charset=UTF-8"));
38curl_setopt($curl, CURLOPT_POST, true);
39curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
40
41$json_response = curl_exec($curl);
42$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
43
44if ( $status != 200 ) {
45 die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
46}
47curl_close($curl);
48
49$response = json_decode($json_response, true);
50var_dump($response);