gocoin/gocoin-php

GoCoin支付处理的PHP库

此包的官方仓库似乎已消失,因此包已被冻结。

维护者

详细信息

github.com/GoCoin/gocoin-php

主页

v0.7 2014-11-11 22:11 UTC

This package is not auto-updated.

Last update: 2023-01-08 20:25:22 UTC


README

GoCoin API的PHP客户端库。推荐:PHP版本 >= 5.3

使用方法

require_once(__DIR__.'/src/GoCoin.php');

//get exchange rates
$exchange = GoCoin::getExchangeRates();

//get current user
$user = GoCoin::getUser($token);
...

//admin functions
require_once(__DIR__.'/src/GoCoinAdmin.php');

//get a list of merchants (admin only function)
$merchants = GoCoinAdmin::listMerchants($token);

//NOTE: by default, the GoCoin class points to the development server
//below is an example of how to switch to production mode

//switch to production mode
$mode = GoCoin::setApiMode('production');

//get an invoice (from production)
$invoice = GoCoin::getInvoice($token,$invoice_id);
...

方法

//return the exchange rates
GoCoin::getExchangeRates()

//return a url to redirect to request an authorization code,
//used later for requesting a token
GoCoin::requestAuthorizationCode($client_id, $client_secret, $scope, $redirect_uri=NULL)

//return an access token given a previously requested authorization code
GoCoin::requestAccessToken($client_id, $client_secret, $code, $redirect_uri=NULL)

用户

//return a user given an id, or, the current user if id is not provided
GoCoin::getUser($token,$id=NULL)

//return an updated user, after applying updates
GoCoin::updateUser($token,$user)

//return the user appplications
GoCoin::getUserApplications($token,$id)

//return a boolean if the password was successfully updated
GoCoin::updatePassword($token,$id,$password_array)

//return a boolean if the reset password request went through
GoCoin::resetPassword($token,$email)

//return a boolean if the reset password with token request went through
GoCoin::resetPasswordWithToken($token,$id,$reset_token,$password_array)

//return a boolean if the request confirmation email request went through
GoCoin::requestConfirmationEmail($token,$email)

//return a boolean if the user confirm was successful
GoCoin::confirmUser($token,$id,$confirm_token)

商户

//return a merchant given an id
GoCoin::getMerchant($token,$id)

//return an updated merchant, after applying updates
GoCoin::updateMerchant($token,$merchant)

//return the result of requesting a payout
GoCoin::requestPayout($token,$merchant_id,$amount,$currency='BTC')

//return a list of merchant payouts given a payout id, or, all payouts if id is not provided
GoCoin::getMerchantPayouts($token,$merchant_id,$payout_id=NULL)

//return the result of requesting a currency conversion
GoCoin::requestCurrencyConversion(
  $token,$merchant_id,$amount,$currency='BTC',$target='USD'
)

//return a list of currency conversions given a conversion id, or, all conversions if id is not provided
GoCoin::getCurrencyConversions($token,$merchant_id,$conversion_id=NULL)

商户用户

//return a list of merchant users given a merchant id
GoCoin::getMerchantUsers($token,$merchant_id)

发票

//return the result of creating an invoice
GoCoin::createInvoice($token,$merchant_id,$invoice)

//return an invoice by id
GoCoin::getInvoice($token,$id)

//return the invoices that match the given criteria
GoCoin::searchInvoices($token,$criteria=NULL)

账户

//return the accounts for a given merchant
GoCoin::getAccounts($token,$merchant_id)

//return the transactions that match the given criteria
GoCoin::getAccountTransactions($token,$account_id,$criteria=NULL)

管理员方法

用户

//return a list of users
GoCoinAdmin::listUsers($token)

//return a created user
GoCoinAdmin::createUser($token,$user)

//return a boolean representing the successful delete of a user
GoCoinAdmin::deleteUser($token,$id)

商户

//return an array of merchants
GoCoinAdmin::listMerchants($token)

//return an array of merchants
GoCoinAdmin::createMerchant($token,$merchant)

//return a merchant object after deleting it
GoCoinAdmin::deleteMerchant($token,$merchant_id)

商户用户

//return the result of adding a user to a merchant account
GoCoinAdmin::addMerchantUser($token,$merchant_id,$user_id)

//return the result of deleting a user from a merchant account
GoCoinAdmin::deleteMerchantUser($token,$merchant_id,$user_id)

运行单元测试

注意:必须安装ANT并确保它在您的PATH中

注意:必须安装PHPUnit并确保它在您的PATH中

注意:您可能需要在src/GoCoin.php中填写TEST_HOST和TEST_DASHBOARD_HOST常量

  • 执行ANT目标phpunit,即:ant phpunit

注意:在第一次执行时,它将copy test/unit/config_test.phptest/unit/config.php。它还将运行一个最小的测试,该测试不需要任何客户端ID、密钥、令牌等。

  • 在config.php中定义以下变量

    • CLIENT_ID
    • CLIENT_SECRET
    • TOKEN
    • USER_ID
    • MERCHANT_ID
    • INVOICE_ID
    • ACCOUNT_ID
    • MERCHANT_USER_ID

注意:如果您不知道相应的ID,可以使用API获取它们

  • 将test/unit/GoCoinTest.php中的MINIMAL_TEST常量更改为FALSE

  • 执行ANT目标phpunit,即:ant phpunit

注意:要执行完整的ANT脚本,进行完整的持续集成和静态分析,您必须安装此处列出的所有PHP工具,即:phpmd、phpDox等。

许可

版权所有 2014 GoCoin Pte. Ltd.

根据Apache License,版本2.0(“许可证”)许可;除非遵守许可证规定或书面同意,否则不得使用此文件。您可以在以下位置获取许可证副本:

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”提供,不提供任何明示或暗示的保证或条件。有关许可证的具体语言管理权限和限制,请参阅许可证。