codehouse/estcard

Nets EstCard 实现

1.0.1 2018-02-25 18:20 UTC

This package is not auto-updated.

Last update: 2024-09-17 17:25:23 UTC


README

初始化服务

<?php
$pathToPrivateKey = '/testkeys/private.key';
$pathToPublicKey = '/testkeys/public.key';
$postBack = 'https://'.$_SERVER['HTTP_HOST'] . '/payment';
$estCardId = '318DC77DC8';
$estCardUrl = 'https://pos.estcard.ee/test-pos/iPayServlet';
$estCard = new \CodeHouse\EstCard\EstCardImpl($pathToPrivateKey, $pathToPublicKey, $postBack, $estCardId, $estCardUrl);

当服务初始化时,创建一个提交给服务提供商的隐藏HTML表单

<?php 
/**
 * @var \CodeHouse\EstCard\EstCard $service
 **/ 
$amountInCents = 10000;
$service->getHtmlForm($amountInCents);

该表单的ID为 estcard,要将表单发送到Nets,请使用jQuery $('#estcard').submit()。可以使用以下代码片段验证响应:

<?php 
/**
 * @var \CodeHouse\EstCard\EstCard $service
 **/ 
$result = $service->validateResponse($_REQUEST);
if ($result == \CodeHouse\EstCard\EstCard::VALIDATE_OK && $response['respcode'] == \CodeHouse\EstCard\EstCard::PAYMENT_OK) {
        // success
}
// signature failed, or payment was not processed

信息

更多信息请访问 https://www.nets.eu/etee/Pages/Test-keskkond.aspx