julianmc90/place-to-pay-sdk

此包的最新版本(dev-master)没有可用的许可证信息。

PHP版的PlaceToPay SDK

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

This package is not auto-updated.

Last update: 2024-09-23 14:44:19 UTC


README

PlaceToPaySDK For PHP

要求

  • ext-soap
  • memcached

安装

使用composer安装

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

需要此自动加载

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

use PlaceToPay\PlaceToPay;

创建和配置一个PlaceToPay对象

/**
 * 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' => ''
	]);

获取银行列表

获取银行列表是从缓存中加载的,每天刷新一次

$placeToPay->getBankList();

设置PSE交易请求

/**
 * 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 follows the next format
 * @var array
 */
$additionalData = Array();

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

交易请求需要以下信息

/**
 * 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
        ]);

创建并发送交易

$placeToPay->createTransaction();

// Get transaction information

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

$placeToPay->getTransactionInformation($identifier);

设置PSE交易多信用请求

需要设置信用

/**
 * 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' 	=>''
];

多信用交易请求需要以下信息

$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
    ]);

创建并获取交易响应

$placeToPay->createTransactionMultiCredit();

注意

这是为了测试我在PlaceToPay公司的技能而制作的