api - Magento 2 - 信用卡详细信息未通过订单保存
问题描述
在这里使用最新的 Magento 2.3.0,其中我有一个自定义模块,它通过 API 调用以编程方式创建订单。
一切正常,到目前为止我只是设置了payment method
(用于测试/开发),我没有添加任何信用卡详细信息。
现在我正在模拟通过 Authorize.net 的信用卡支付。使用正确的沙盒帐户设置配置 Mage 2 管理员,并在自定义模块中的订单中添加信用卡详细信息,但交易未显示在我的 Auth.net 沙盒帐户中 - 这Authorization
仅用于捕获/收费.
仔细检查后,我假设 cc 详细信息未添加到订单中(仅添加到报价中),因此提交时的订单未授权交易......(这是我的假设)
这是我用来将 cc 详细信息添加到报价单的代码:
$quote->getPayment()->importData(
[
'method' => "authorizenet_directpost",
'cc_type' => $orderData['cc_data']['cc_type'],
'cc_owner' => $orderData['cc_data']['cc_holder'],
'cc_last_4' => substr($orderData['cc_data']['cc_num'], -4),
'cc_number' => $orderData['cc_data']['cc_num'],
'cc_cid' => $orderData['cc_data']['cc_ccv'],
'cc_exp_month' => $orderData['cc_data']['cc_exp_month'],
'cc_exp_year' => $orderData['cc_data']['cc_exp_year']
]
);
第一个问题:
(1) 这些是 cc 详细信息的正确字段名称吗?(2) 是否需要所有这些字段(例如 cc_type)?
然后将报价转换为订单:
$quote->collectTotals()->save();
$order = $this->quoteManagement->submit($quote);
$this->orderSender->send($order);
同样,订单创建时没有任何错误,在管理订单详细信息视图中,我可以看到付款信息为Credit Card Direct Post (Authorize.net)
,但根本没有 cc 详细信息。
db表quote_payment
有 cc 数据。
最后的问题:
(3) 为什么订单中没有正确添加抄送信息,并且没有进行授权?(4) 我是否需要将 cc 详细信息添加到 order 对象而不是 quote 对象?
注意:当我尝试为这些测试订单开具发票时,它会失败 w/ Gateway error: Credit card number is required.
,所以很明显,订单中缺少 cc 详细信息...
谢谢 !