超荷/超荷模式

超荷 API JSON 模式

1.25.4 2015-12-14 10:41 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:39:18 UTC


README

超荷支付请求数据的 json 模式

匹配 超荷-API-doc 版本 2.24 2014/09/16

Build Status Gem Version

固定数据

提供了一系列超荷 API XML 请求、响应和通知作为 /test/fixtures/ 中的固定数据

提供 php、ruby 和 javascript 的固定数据加载器。

php

// requests to hypercharge
$xmlString = Hypercharge\JsonSchemaFixture::request('sale.xml');

// or as json string
$jsonString = Hypercharge\JsonSchemaFixture::request('sale.json');

// response from hypercharge
$xmlString = Hypercharge\JsonSchemaFixture::response('sale.xml');

// notification from hypercharge
$postData = json_decode(Hypercharge\JsonSchemaFixture::notification('transaction_notification.json'), true);

ruby

# request to hypercharge
xmlString = Hypercharge::Schema::Fixture.xml 'requests/sale'

# or as parsed json
jsonData = Hypercharge::Schema::Fixture.json 'requests/sale'

# response from hypercharge
xmlString = Hypercharge::Schema::Fixture.xml 'responses/sale'

# notification from hypercharge
jsonData = Hypercharge::Schema::Fixture.json 'notifications/transaction_notification'

javascript(目前没有异步)

var Schema = require('hypercharge-schema').Schema;

// request to hypercharge
var xmlString = Schema.Fixture.xml('requests/sale');

// or as parsed json
var jsonData = Schema.Fixture.json('requests/sale');

// response from hypercharge
var xmlString = Schema.Fixture.xml('responses/sale');

// notification from hypercharge
var postData = Schema.Fixture.json('notifications/transaction_notification');

测试

假设你已经安装了所有依赖项(见下文),你可以一次性运行所有测试(ruby、php、javascript)。

./test/all.sh

或逐个运行

Ruby

ruby >= 1.9.3

安装依赖项

bundle

运行测试

rake

PHP

php >= 5.3

安装 Composer 和依赖项

curl -o composer.phar https://getcomposer.org.cn/composer.phar
php composer.phar install
php composer.phar update --dev

运行测试

php test/php/all.php

JavaScript

安装 node.js

安装依赖项

npm install

运行测试

npm test

顺便说一句:nvm 是一个在单一机器上安装和处理多个 node.js 版本的有用工具。

保修

此软件按“现状”提供,不提供任何明确的或暗示的保证,包括但不限于适销性和特定目的的适用性保证。