julianmc90/place-to-pay-sdk

There is no license information available for the latest version (dev-master) of this package.

PlaceToPay SDK for PHP

dev-master 2017-01-14 06:50 UTC

This package is not auto-updated.

Last update: 2024-10-07 14:54:16 UTC


README

PlaceToPaySDK For PHP

Requirements

  • ext-soap
  • memcached

Installation

Install using composer

composer require julianmc90/place-to-pay-sdk:dev-master@dev

Require this autoload

require_once __DIR__ . '/vendor/autoload.php';

use PlaceToPay\PlaceToPay;

Create and configure a PlaceToPay Object

/**
 * Setting PlaceToPay Object 
 * @var PlaceToPay
 */
$placeToPay =  new PlaceToPay([
        /**
         * Web service Url
         */
		'wsdl'   => 'https://test.placetopay.com/soap/pse/?wsdl',
		
        /**
         * Login 
         */
        'login'  => '6dd490faf9cb87a9862245da41170ff2',
		
        /**
         * Transactional Key
         */
        'tranKey'=> '024h1IlD',

        /**
         * Timezone (Optional) defaults to America/Bogota
         */
        //'timeZone' => ''
	]);

Getting Bank List

To get the bank list, this is loaded from cahe and refreshed each day

$placeToPay->getBankList();

Setting up a PSE Transaction Request

/**
 * payer, buyer and shipping follows the next format
 * @var Array
 */
$payer = Array(
        'document'     => '',
        'documentType' => '',
        'firstName'    => '',
        'lastName'     => '',
        'company'      => '',
        'emailAddress' => '',
        'address'      => '',
        'city'         => '',
        'province'     => '',
        'country'      => '',
        'phone'        => '',
        'mobile'       => ''
);

Additional data

/**
 * Additional data follows the next format
 * @var array
 */
$additionalData = Array();

/**
 * could be added more indexes to fit your needs
 */
$additionalData[] = ['name'=>'', 'value'=>''];

The transaction request need the following information

/**
 * To set the Transaction request
 * follow this format 
 */
$placeToPay->setPseTransactionRequest([
	        'bankCode'		=> '', 
	        'bankInterface'	=> '', 
	        'returnURL'		=> '', 
	        'reference'		=> '', 
	        'description'	=> '', 
	        'language'		=> '', 
	        'currency'		=> '', 
	        'totalAmount'	=> 0, 
	        'taxAmount'		=> 0,  
	        'devolutionBase'=> 0, 
	        'tipAmount'		=> 0, 
	        'payer'			=> $payer,
	        'buyer'			=> $buyer,
	        'shipping'		=> $shipping,
	        'additionalData'=> $additionalData
        ]);

Create and send the transaction

$placeToPay->createTransaction();

// Get transaction information

/**
 * needs a transaction identifier
 * @type {Number}
 */
$identifier = 1234;

$placeToPay->getTransactionInformation($identifier);

Setting up a PSE Transaction MultiCredit Request

Needs Credits to be setup

/**
 * Credits follows the next format
 * @var array
 */
$credits = [];

/**
 * could be added more indexes to fit your needs
 */
$credits[] = [
    'entityCode' 	=>'',
    'serviceCode' 	=>'',
    'amountValue' 	=>0,
    'taxValue' 		=> 0,
    'description' 	=>''
];

The transaction multicredit request needs the following information

$placeToPay->setPseTransactionMultiCreditRequest([
         'bankCode'      => '', 
         'bankInterface' => '', 
         'returnURL'     => '', 
         'reference'     => '', 
         'description'   => '', 
         'language'      => '', 
         'currency'      => '', 
         'totalAmount'   => 0, 
         'taxAmount'     => 0,  
         'devolutionBase'=> 0, 
         'tipAmount'     => 0, 
         'payer'         => $payer,
         'buyer'         => $buyer,
         'shipping'      => $shipping,
         'additionalData'=> $additionalData,
         'credits' => $credits
    ]);

Creates and gets the transaction response

$placeToPay->createTransactionMultiCredit();

Note

This is made for a testing my skills for PlaceToPay company