【发布时间】:2019-07-26 22:02:17
【问题描述】:
上下文:我尝试设置LexikPaybox 捆绑包。我按照自述文件中的安装指南进行操作。
问题:$paybox->getUrl() 方法引发
警告:DOMDocument::loadHTML():作为输入提供的空字符串
地址返回:
dump($this->getWebPage(sprintf(
'%s://%s%s',
$server['protocol'],
$server['host'],
$server['test_path']
)));
>>> "https://preprod-tpeweb.paybox.com/load.html"
然后,getWebPage()(第 163 行)返回一个空字符串,该字符串在 $doc->loadHTML() 中引发错误。
我的研究:
-
有完全相同的问题here。但是,没有明确的答案。
如果我运行
curl https://tpeweb.paybox.com/load.html,我会得到预期的 html 输出。 -
有很多类似的帖子处理上述错误。但是,我不认为这是模块的代码错误,而是我缺少的更多内容。
配置:
Config.yml:
# Lexik Paybox Bundle
lexik_paybox:
parameters:
production: false # Switches between Paybox test and production servers (preprod-tpe <> tpe)
# Site number provided by the bank
site: '1999888'
# Rank number provided by the bank
rank: '32'
rang: '32'
# Customer's login provided by Paybox
login: '2'
hmac:
# Key used to compute the hmac hash, provided by Paybox
key: '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'
algorithm: sha512 # signature algorithm
signature_name: Sign # customize the signature parameter name
currencies: # Optionnal parameters, this is the default value
- '978' # EUR
routing.yml:
# Lexik Paybox Bundle
lexik_paybox:
resource: '@LexikPayboxBundle/Resources/config/routing.yml'
lexik_paybox_sample_return:
path: /payment/return/{status}
defaults: { _controller: LexikPayboxBundle:Sample:return, status: error }
requirements:
status: success|canceled|denied
PaymentController.php:
<?php
namespace Modules\ReservationBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PaymentController extends Controller {
/**
* Sample action to call a payment.
* It create the form to submit with all parameters.
* @Route("/paiemant", name="paiemant")
*/
public function callAction()
{
$paybox = $this->get('lexik_paybox.request_handler');
$paybox->setParameters(array(
'PBX_CMD' => 'CMD'.time(),
'PBX_DEVISE' => '978',
'PBX_SITE' => '1999888',
'PBX_IDENTIFIANT' => '107904482',
'PBX_RANG' => '32',
'PBX_PORTEUR' => 'test@paybox.com',
'PBX_RETOUR' => 'Mt:M;Ref:R;Auto:A;Erreur:E',
'PBX_TOTAL' => '1000',
'PBX_TYPEPAIEMENT' => 'CARTE',
'PBX_TYPECARTE' => 'CB',
'PBX_EFFECTUE' => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'success'), UrlGeneratorInterface::ABSOLUTE_URL),
'PBX_REFUSE' => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'denied'), UrlGeneratorInterface::ABSOLUTE_URL),
'PBX_ANNULE' => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'canceled'), UrlGeneratorInterface::ABSOLUTE_URL),
'PBX_RUF1' => 'POST',
'PBX_REPONDRE_A' => $this->generateUrl('lexik_paybox_ipn', array('time' => time()), UrlGeneratorInterface::ABSOLUTE_URL),
// 'PBX_TOTAL' => '1000',
// 'PBX_DEVISE' => '978',
// 'PBX_CMD' => 'CMD'.time(),
// 'PBX_PORTEUR' => 'test@paybox.com',
// 'PBX_RETOUR' => 'Mt:M;Ref:R;Auto:A;Erreur:E',
));
return $this->render(
'LexikPayboxBundle:Sample:index.html.twig',
array(
'url' => $paybox->getUrl(),
'form' => $paybox->getForm()->createView(),
)
);
}
/**
* Sample action of a confirmation payment page on witch the user is sent
* after he seizes his payment informations on the Paybox's platform.
* This action must only containts presentation logic.
*/
public function responseAction($status)
{
return $this->render(
'LexikPayboxBundle:Sample:return.html.twig',
array(
'status' => $status,
'parameters' => $this->getRequest()->query,
)
);
}
}
【问题讨论】:
标签: php symfony payment paybox