floospaynet / floospayapi
floospay支付API服务提供商
dev-master / 1.0.x-dev
2018-12-22 12:22 UTC
Requires
- php: >=5.6.4
This package is auto-updated.
Last update: 2024-09-23 01:36:49 UTC
README
Floospay支付API服务提供商
composer require floospaynet/floospayapi "1.0.x-dev"
Floospay Laravel PHP库
该库为开发者提供了一套简单的绑定,用于连接Floospay支付API、托管结账、即时通知服务和管理API。
使用方法:下载或克隆仓库。
git clone https://github.com/floospaynet/floospayapi.git
在您的PHP脚本中引入。
require_once("/path/to/floospaynet/floospayapi/lib/FloospayApi.php");
默认情况下,所有方法都返回一个数组,或者您可以设置格式为'json'以获取JSON响应。示例:
<?php FloospayApi::format('json');
凭证和选项
提供了以下凭证和选项的设置方法。
<?php // Your sellerId(account number) and privateKey are required to make the Payment API Authorization call. FloospayApi::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996'); FloospayApi::sellerId('901248204'); // Your username and password are required to make any Admin API call. FloospayApi::username('testlibraryapi901248204'); FloospayApi::password('testlibraryapi901248204PASS'); // If you want to turn off SSL verification (Please don't do this in your production environment) FloospayApi::verifySSL(false); // this is set to true by default // To use your sandbox account set sandbox to true FloospayApi::sandbox(true); // All methods return an Array by default or you can set the format to 'json' to get a JSON response. FloospayApi::format('json');
每个绑定的完整文档提供在 wiki。
示例支付API使用
示例请求
<?php FloospayApi::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996'); FloospayApi::sellerId('901248204'); try { $charge = Floospay_Charge::auth(array( "sellerId" => "901248204", "merchantOrderId" => "123", "token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk', "currency" => 'USD', "total" => '10.00', "billingAddr" => array( "name" => 'Testing Tester', "addrLine1" => '123 Test St', "city" => 'Columbus', "state" => 'OH', "zipCode" => '43123', "country" => 'USA', "email" => 'testingtester@2co.com', "phoneNumber" => '555-555-5555' ), "shippingAddr" => array( "name" => 'Testing Tester', "addrLine1" => '123 Test St', "city" => 'Columbus', "state" => 'OH', "zipCode" => '43123', "country" => 'USA', "email" => 'testingtester@2co.com', "phoneNumber" => '555-555-5555' ) )); $this->assertEquals('APPROVED', $charge['response']['responseCode']); } catch (Floospay_Error $e) { $this->assertEquals('Unauthorized', $e->getMessage()); }
示例响应
Array ( [validationErrors] => [exception] => [response] => Array ( [type] => AuthResponse [lineItems] => Array ( [0] => Array ( [options] => Array ( ) [price] => 10.00 [quantity] => 1 [recurrence] => [startupFee] => [productId] => [tangible] => N [name] => 123 [type] => product [description] => [duration] => ) ) [transactionId] => 205181140830 [billingAddr] => Array ( [addrLine1] => 123 Test St [addrLine2] => [city] => Columbus [zipCode] => 43123 [phoneNumber] => 555-555-5555 [phoneExtension] => [email] => testingtester@2co.com [name] => Testing Tester [state] => OH [country] => USA ) [shippingAddr] => Array ( [addrLine1] => 123 Test St [addrLine2] => [city] => Columbus [zipCode] => 43123 [phoneNumber] => [phoneExtension] => [email] => [name] => Testing Tester [state] => OH [country] => USA ) [merchantOrderId] => 123 [orderNumber] => 205181140821 [recurrentInstallmentId] => [responseMsg] => Successfully authorized the provided credit card [responseCode] => APPROVED [total] => 10.00 [currencyCode] => USD [errors] => ) )
示例管理API使用
示例请求
<?php FloospayApi::username('testlibraryapi901248204'); FloospayApi::password('testlibraryapi901248204PASS'); $args = array( 'sale_id' => 4834917619 ); try { $result = Floospay_Sale::stop($args); } catch (Floospay_Error $e) { $e->getMessage(); }
示例响应
<?php [response_code] => OK [response_message] => Array ( [0] => 4834917634 [1] => 4834917646 [2] => 4834917658 )
示例结账使用
示例请求
<?php $params = array( 'sid' => '1817037', 'mode' => 'standard', 'li_0_name' => 'Test Product', 'li_0_price' => '0.01' ); Floospay_Charge::form($params, 'auto');
示例响应
<form id="floospay-form" action="https://www.floospay.net/checkout/spurchase" method="post"> <input type="hidden" name="sid" value="1817037"/> <input type="hidden" name="mode" value="standard"/> <input type="hidden" name="li_0_name" value="Test Product"/> <input type="hidden" name="li_0_price" value="0.01"/> <input type="submit" value="Click here if you are not redirected automatically" /></form> <script type="text/javascript">document.getElementById('floospay-form').submit();</script>
示例返回使用
示例请求
<?php $params = array(); foreach ($_REQUEST as $k => $v) { $params[$k] = $v; } $passback = Floospay_Return::check($params, "tango");
示例响应
<?php [response_code] => Success [response_message] => Hash Matched
示例INS使用
示例请求
<?php $params = array(); foreach ($_POST as $k => $v) { $params[$k] = $v; } $passback = Floospay_Notification::check($params, "tango");
示例响应
<?php [response_code] => Success [response_message] => Hash Matched
异常
如果返回错误,将抛出Floospay_Error异常。最好捕获这些异常,以便在您的应用程序中以优雅的方式处理。
示例使用
<?php FloospayApi::username('testlibraryapi901248204'); FloospayApi::password('testlibraryapi901248204PASS'); $params = array( 'sale_id' => 4774380224, 'category' => 1, 'comment' => 'Order never sent.' ); try { $sale = Floospay_Sale::refund($params); } catch (Floospay_Error $e) { $e->getMessage(); }
每个绑定的完整文档提供在 wiki。