PlacetoPay PSE SDK for PHP
, (*1)
Use PlacetoPay PSE service in your PHP project, (*2)
Requirements
-
XML and SOAP extensions must be enabled
Installattion
Add alejobit/placetopay-pse-php
as a require dependency in your composer.json
file:, (*3)
composer require alejobit/placetopay-pse-php
For the best operation of the client it is necessary to implement a caching library compatible with the standard PSR-6., (*4)
If your project does not have a compatible implementation, you can proceed to install the following library:, (*5)
composer require symfony/cache
Usage
Create a PSE client instance, note that the $login
and $tranKey
are given by PlacetoPay to be able to perform transactions on behalf of a collection site, (*6)
use PlacetoPay\PSE\PSE;
$pse = new PSE($login, $tranKey);
Setting the PSR-6 cache adapter instance (which must implement Psr\Cache\CacheItemPoolInterface
), (*7)
$pse->setCacheAdapter(CacheItemPoolInterface $cacheAdapter);
Obtains the list of banks available for the trading establishment in the PSE system of ACH Colombia, (*8)
This method returns a PlacetoPay\PSE\Struct\ArrayOfBanks
object (which implements \Iterator
and \Countable
interfaces), (*9)
$bankList = $pse->getBankList();
Create transactions with the createTransaction()
and createTransactionMultiCredit()
methods:, (*10)
$transaction = $pse->createTransaction();
$multiCreditTransaction = $pse->createTransactionMultiCredit();
Load the transaction information as follows:, (*11)
$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');
MultiCredit transactions have an additional method to add credit concepts of the same as follows, (*12)
$multiCreditTransaction->addCreditConcept(array(
'entityCode'=> '123456',
'serviceCode' => '654321',
'amountValue' => 12345.6,
'taxValue' => 0.0,
'description' => 'Description of credit concept',
));
Once loaded all the necessary data is sent the transaction with the method send()
, (*13)
The send()
method return a PlacetoPay\PSE\Struct\PSETransactionResponse
with the result of the operation, (*14)
$response = $transaction->send()
To obtain the information of a specific transaction can use the method getTransactionInformation($id)
passing the unique identifier of the transaction to consult, (*15)
$transactionInfo = $pse->getTransactionInformation($response->getTransactionId());