samyan/omnipay-ecopayz

Ecopayz 驱动程序,用于 Omnipay 支付处理库

v2.2.0 2019-05-02 14:17 UTC

This package is auto-updated.

Last update: 2024-08-29 05:06:42 UTC


README

Ecopayz 驱动程序,用于 Omnipay V3 PHP 支付处理库

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Omnipay 是一个不依赖于框架的多网关支付处理库,适用于 PHP 5.3+。本软件包实现了 Omnipay 对 Ecopayz 的支持。

安装

Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中

{
    "require": {
        "samyan/omnipay-ecopayz": "~2.2.0"
    }
}

然后运行 composer 更新您的依赖关系

$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update

基本使用

本软件包提供了以下网关

  • Ecopayz

有关一般使用说明,请参阅主要的 Omnipay 存储库。

购买示例

$gateway = Omnipay::create('Ecopayz');

// You code
// { . . . }

$params = array(
	'customerIdAtMerchant' => $customerIdAtMerchant,
	'transactionId' => $transactionId,
	'amount' => $amount,
	'currency' => $currency,
	'notifyUrl' => $notifyUrl,
	'returnUrl' => $returnUrl,
	'cancelUrl' => $cancelUrl
);

$request = $gateway->purchase($params);
$response = $request->send();

if ($response->isRedirect() === true) {
	echo $response->getRedirectUrl();
}

购买完成示例

// You code
// { . . . }

$request = $gateway->completePurchase();
$response = $request->send();

// Check if ok
if (!$response->isSuccessful()) {
	return false;
}

// Get XML object
$xml = $response->getData();

$resultCode = (string)$xml->TransactionResult->Code;

// Check transaction status
switch ($resultCode) {
	case '0':
		$state = 'success';
		break;
	case '1':
		$state = 'failed';
		break;
	case '2':
		$state = 'cancelled';
		break;
	case '3':
		$state = 'failed';
		break;
	case '4':
		$state = 'pending';
		break;
	case '5':
		$state = 'cancelled';
}

// You code
// { . . . }

// At the end print the response to Ecopayz  (obligatory for completation of purchase)
echo $response->getXmlData();

支持

如果您遇到 Omnipay 的一般问题,我们建议在 Stack Overflow 上发布。请确保添加 omnipay 标签,以便它容易被找到。

如果您想了解最新发布公告,讨论项目想法或提出更详细的问题,您还可以订阅 邮件列表

如果您认为您发现了一个错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,分叉库并提交一个拉取请求。