alejobit/placetopay-pse-php

在您的PHP项目中使用PlacetoPay PSE服务

0.2.0 2017-08-16 12:39 UTC

This package is auto-updated.

Last update: 2024-09-25 12:19:56 UTC


README

Build Status StyleCI

在您的PHP项目中使用PlacetoPay PSE服务

要求

  • XML和SOAP扩展必须启用

安装

在您的composer.json文件中将alejobit/placetopay-pse-php添加为require依赖项

composer require alejobit/placetopay-pse-php

为了客户端的最佳运行,需要实现一个与标准PSR-6兼容的缓存库。

如果您的项目没有兼容的实现,您可以继续安装以下库

composer require symfony/cache

使用方法

创建一个PSE客户端实例,请注意,$login$tranKey是由PlacetoPay提供的,以便能够代表收款网站执行交易

use PlacetoPay\PSE\PSE;

$pse = new PSE($login, $tranKey);

设置PSR-6缓存适配器实例(必须实现Psr\Cache\CacheItemPoolInterface

$pse->setCacheAdapter(CacheItemPoolInterface $cacheAdapter);

获取ACH哥伦比亚PSE系统中贸易场所可用的银行列表

此方法返回一个PlacetoPay\PSE\Struct\ArrayOfBanks对象(实现了\Iterator\Countable接口)

$bankList = $pse->getBankList();

使用createTransaction()createTransactionMultiCredit()方法创建交易

$transaction = $pse->createTransaction();
$multiCreditTransaction = $pse->createTransactionMultiCredit();

按照以下方式加载交易信息

$transaction->setBankCode($bank->getCode());
$transaction->setBankInterface(Bank::PERSONAL_INTERFACE);
$transaction->setReturnURL('https://www.placetopay.com');
$transaction->setReference(md5('reference'));
$transaction->setDescription('Description of transaction');
$transaction->setLanguage('ES');
$transaction->setCurrency('COP');
$transaction->setTotalAmount(12345.6);
$transaction->setTaxAmount(0.0);
$transaction->setDevolutionBase(0.0);
$transaction->setTipAmount(0.0);
$transaction->setPayer(array(
    'documentType' => 'CC',
    'document' => '123456789',
    'firstName' => 'Foo',
    'lastName' => 'Bar',
    'company' => 'PlacetoPay',
    'emailAddress' => 'info@placetopay.com',
    'address' => 'Calle 53 No. 45 – 112 OF. 1901',
    'city' => 'Medellín',
    'province' => 'Antioquia',
    'country' => 'CO',
    'phone' => '+57 (4) 444 2310',
    'mobile' => '+57 (4) 444 2310',
));
$transaction->setIpAddress('127.0.0.1');
$transaction->addAdditionalData('name', 'value');

多信用交易有一个额外的方法来添加相同的信用概念,如下所示

$multiCreditTransaction->addCreditConcept(array(
    'entityCode'=> '123456',
    'serviceCode' => '654321',
    'amountValue' => 12345.6,
    'taxValue' => 0.0,
    'description' => 'Description of credit concept',
));

加载所有必要的数据后,使用send()方法发送交易

send()方法返回一个包含操作结果的PlacetoPay\PSE\Struct\PSETransactionResponse

$response = $transaction->send()

要获取特定交易的信息,可以使用getTransactionInformation($id)方法,传入要查询的交易的唯一标识符

$transactionInfo = $pse->getTransactionInformation($response->getTransactionId());

相关项目