123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- class Demo extends Api
- {
-
-
-
-
-
- protected $noNeedLogin = ['test', 'test1'];
-
- protected $noNeedRight = ['test2'];
-
- public function test()
- {
- $apiKey = '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e';
- $salt = 'LNrFYxOiGhtdHAuJiqqy3wOl1nVwyJn5dfOYkLquFx8j2J6bm2nsplTnpkYuKyo5';
- $hitPayClient = new \HitPay\Client($apiKey, false);
- try {
- $request = new \HitPay\Request\CreatePayment();
- $request->setAmount(66)
- ->setCurrency('SGD');
- $result = $hitPayClient->createPayment($request);
- print_r($result);
- $data = $hitPayClient->getPaymentStatus($result->getId());
- print_r($data);
- $data = $hitPayClient->deletePaymentRequest($data->getId());
- print_r($data);
- } catch (\Exception $e) {
- print_r($e->getMessage());
- }
- }
-
- public function test1()
- {
- $curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_URL => "https://api.sandbox.hit-pay.com/v1/orders",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => [
- "X-BUSINESS-API-KEY: <096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e>"
- ],
- ]);
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- echo $response;
- }
- }
-
- public function test2()
- {
- $this->success('返回成功', ['action' => 'test2']);
- }
-
- public function test3()
- {
- $this->success('返回成功', ['action' => 'test3']);
- }
- }
|