chrismeller/cybersource

此包已被放弃,不再维护。未建议替代包。

一个简单的类,用于与CyberSource SOAP Toolkit API的一些基本方法接口,用于在线处理信用卡交易。

v0.3 2013-07-23 16:51 UTC

This package is not auto-updated.

Last update: 2021-02-28 21:52:16 UTC


README

一个简单的类,用于与CyberSource SOAP Toolkit API的一些基本方法接口,用于在线处理信用卡交易。

CyberSource鼓励使用其简单订单API,该API使用一个自2007年以来未更新的自定义PHP扩展(且不支持64位服务器)。此类避免安装自定义扩展,并提供了快速便捷的SOAP API入口。

许可协议

Copyright 2011 Chris Meller

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

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

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

API 文档

CyberSource提供的文档相当缺乏。如果您需要扩展可用方法,您最好的选择是查看简单订单API文档,并通过SOAP接口尽可能地模拟它。经过一些试验和错误,您会发现它们非常相似。

使用方法

将类包含到您的代码中,并用您的商户ID和交易ID实例化CyberSource

$c = new CyberSource( $merchant_id, $transaction_id );

还提供了一个工厂模式,以实现易于方法链

$result = CyberSource::factory( $merchant_id, $transaction_id )
	->card( '4111111111111111', '12', '2013', '123' )
	->add_item( 5 )
	->charge();

示例

tests目录中有几个单独的示例,展示了如何调用常用方法。

要运行示例,首先在tests/config.php下创建一个文件,包含以下键

<?php

$merchant_id = 'xxx';
$transaction_id = 'yyy';
$username = 'zzz';
$password = 'vvv';

然后运行

$ /path/to/composer.phar dump-autoload

这将创建库类的自动加载文件。现在您可以执行一个示例了

php -d error_reporting=-1 -d display_errors tests/auth_amount.php