/sofa_mock_server_php

Primary LanguagePHPApache License 2.0Apache-2.0

Table of contents

Get Started

Refer to here for detailed introduction.

Deposit Wallet API

Refer to here for detailed API documentation.

Withdraw Wallet API

Refer to here for detailed API documentation.

Query API

Refer to here for detailed API documentation.

Mock Server

Setup configuration

Configure CYBAVO API server URL in mockserver.conf.php

$api_server_url = 'BACKEND_SERVER_URL';

How to run

Required version: PHP 7.3.7 or later (with sqlite3 enabled)

Replace the [SOFA_MOCK_SERVER_PHP_PATH] in the following commands to source code directory.

  • If you have PHP installed then use following command to start the built-in web server.
    • $ cd [SOFA_MOCK_SERVER_PHP_PATH]
    • $ php -S 0.0.0.0:8889
  • Otherwise use docker to setup mock server.
    • $ docker run --name mockserver -d -v [SOFA_MOCK_SERVER_PHP_PATH]:/var/www/html -p 8889:8889 php:7.3.7-fpm
    • $ docker exec -it mockserver bash
    • $ php -S 0.0.0.0:8889

Put wallet API code/secret into mock server

  • Get API code/secret on web console
    • API-CODE, API-SECRET, WALLET-ID
  • Put API code/secret to mock server's database
curl -X POST -H "Content-Type: application/json" -d '{"api_code":"API-CODE","api_secret":"API-SECRET"}' \
http://localhost:8889/v1/mock/wallets/{WALLET-ID}/apitoken

Register mock server callback URL

Operate on web admin console

Notification Callback URL

http://localhost:8889/v1/mock/wallets/callback

Withdrawal Authentication Callback URL

http://localhost:8889/v1/mock/wallets/withdrawal/callback

The withdrawal authentication callback URL once set, every withrawal request will callback this URL to get authentication to proceed withdrawal request.

Refer to /v1/mock/wallets/withdrawal/callback handler function in mock server index.php

NOTE: Because the mock server uses a single-threaded PHP built-in web server as underlying server, it cannot process withdrawal authentication callbacks and withdrawal requests at the same time. While using mock server, please do not set the withdrawal authentication callback URL.

cURL Testing Commands

Refer to here for curl testing commands.

Other Language Versions