我正在开发一个magento 2支付模块,但我遇到了一个问题,我需要包含第三方支付网关php文件,其中多个类被声明为类a,类b,class.cp文件中的类c 我正在使用require_once('magento_path / class.php'); 但它似乎无法正常工作 请帮忙!
- 更新 - 这是我向网关发送请求的代码示例 -
注意:所有变量仅用于示例
public function placeRequest(TransferInterface $transferObject)
{
require_once ("ThePaymentGateway/PaymentSystem.php");
$rgeplRequestGatewayEntryPointList = new RequestGatewayEntryPointList();
$rgeplRequestGatewayEntryPointList->add("gw1.".$PaymentProcessorFullDomain, 100, 1);
$rgeplRequestGatewayEntryPointList->add("https://gw2.".$PaymentProcessorFullDomain, 200, 1);
$rgeplRequestGatewayEntryPointList->add("https://gw3.".$PaymentProcessorFullDomain, 300, 1);
$cdtCardDetailsTransaction = new CardDetailsTransaction($rgeplRequestGatewayEntryPointList);
$cdtCardDetailsTransaction->getMerchantAuthentication()->setMerchantID($MerchantID);
$cdtCardDetailsTransaction->getMerchantAuthentication()->setPassword($Password);
$cdtCardDetailsTransaction->getTransactionDetails()->getMessageDetails()->setTransactionType("SALE");
$cdtCardDetailsTransaction->getTransactionDetails()->getAmount()->setValue($Amount);
$cdtCardDetailsTransaction->getTransactionDetails()->setOrderID($OrderID);
$cdtCardDetailsTransaction->getTransactionDetails()->setOrderDescription($OrderDescription);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoCardType()->setValue(true);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoAmountReceived()->setValue(true);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoAVSCheckResult()->setValue(true);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getEchoCV2CheckResult()->setValue(true);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getThreeDSecureOverridePolicy()->setValue(true);
$cdtCardDetailsTransaction->getTransactionDetails()->getTransactionControl()->getDuplicateDelay()->setValue(60);
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->getDeviceCategory()->setValue(0);
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->setAcceptHeaders("*/*");
$cdtCardDetailsTransaction->getTransactionDetails()->getThreeDSecureBrowserDetails()->setUserAgent($_SERVER["HTTP_USER_AGENT"]);
$cdtCardDetailsTransaction->getCardDetails()->setCardName($CardName);
$cdtCardDetailsTransaction->getCardDetails()->setCardNumber($CardNumber);
$cdtCardDetailsTransaction->getCardDetails()->setIssueNumber($IssueNumber);
$cdtCardDetailsTransaction->getCardDetails()->setCV2($CV2);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress1($Address1);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress2($Address2);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress3($Address3);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setAddress4($Address4);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setCity($City);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setState($State);
$cdtCardDetailsTransaction->getCustomerDetails()->getBillingAddress()->setPostCode($PostCode);
$cdtCardDetailsTransaction->getCustomerDetails()->setEmailAddress("test@test.com");
$cdtCardDetailsTransaction->getCustomerDetails()->setPhoneNumber("123456789");
$cdtCardDetailsTransaction->getCustomerDetails()->setCustomerIPAddress($_SERVER["REMOTE_ADDR"]);
$boTransactionProcessed = $cdtCardDetailsTransaction->processTransaction($cdtrCardDetailsTransactionResult, $todTransactionOutputData);
if ($boTransactionProcessed == false)
{
// could not communicate with the payment gateway
$NextFormMode = "PAYMENT_FORM";
$Message = "Couldn't communicate with payment gateway";
PaymentFormHelper::reportTransactionResults($OrderID, 30, $Message, null);
}
else
{
echo "Payment Success";
}
}
所有支付网关类都在payzone提供的Paymentsystem.php中定义,但这里require_once似乎无法正常工作
答案 0 :(得分:1)
Magento有一种方法来开发自己的自定义模块。如果您不遵循此方法,那么您将遇到路径错误,例如您正在谈论的路径错误,特别是在您有大量验证和安全方式的支付模块中。
我建议查看此页面。 http://alanstorm.com/category/magento-2/page/3/
他创建了一个名为PESTLE的框架,可以更轻松地创建自定义模块http://alanstorm.com/magento2_pestle_code_generation/
检查出来。