Magento:如何从使用付款方式提交的字段中检索值?

发布于 2024-09-05 00:13:47 字数 277 浏览 0 评论 0原文

好的。这有点令人沮丧。我正在尝试为 Magento 创建一个自定义支付模块。目的是使用Authorize.net的CIM,这样我们就不用太担心PCI合规性了。我遇到的问题是用户需要能够访问他们以前的信用卡并使用这些信用卡进行购买。我将以前的卡片存储在数据库中。它们也会在结帐过程中以表格形式显示。

当我选择付款方式后单击“继续”时,我的问题出现了。如何获取我在表单中提交的值?具体来说,保存的代码附加到的单选按钮的值?

我不确定我是否需要发布任何代码,所以如果您有特别需要,请告诉我。

谢谢。

Ok. This is getting a little frustrating. I am trying to create a custom payment module for Magento. The purpose is to use Authorize.net's CIM so that we don't have to worry so much about PCI compliance. The issue I am having is that the users need to be able to access their previous credit cards and use those for purchasing. I have the previous cards being stored in the database. They are also being displayed in the form in the checkout process.

My issue comes when I click continue after selecting the payment method. How do I get the values I submitted in the form? Specifically, the value of the radio button the saved code is attached to?

I am not sure what if any code is needed for me to post, so let me know if you need anything in particular.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

峩卟喜欢 2024-09-12 00:13:47

在一些好地方,您的付款方式可以使用此帖子数据。

访问发布数据字段的最佳位置是重写付款方法类中的 allocateData 方法。它应该看起来像这样:

/**
 * Assign data to info model instance
 */
public function assignData($data)
{
    // Call parent assignData
    parent::assignData($data);

    // Get Mage_Payment_Model_Info instance from quote 
    $info = $this->getInfoInstance();

    // Add some arbitrary post data to the Mage_Payment_Model_Info instance 
    // so it is saved in the DB in the 'additional_information' field        
    $info->setAdditionalInformation(
        'arbitrary_post_field', 
        $data['arbitrary_post_field'];

    return $this;
}

或者,您可以重写 Mage_Sales_Model_Quote_Payment::importData() 和 Mage_Checkout_Model_Type_Onepage::savePayment,这为您提供了更大的灵活性,因为这些方法将在 Magento 根据付款代码选择您的特定付款方式之前被调用。

There are a few good places where this post data is available to your payment method.

The best place to gain access to the post data fields is to override the assignData method in your payment method class. It should look something like this:

/**
 * Assign data to info model instance
 */
public function assignData($data)
{
    // Call parent assignData
    parent::assignData($data);

    // Get Mage_Payment_Model_Info instance from quote 
    $info = $this->getInfoInstance();

    // Add some arbitrary post data to the Mage_Payment_Model_Info instance 
    // so it is saved in the DB in the 'additional_information' field        
    $info->setAdditionalInformation(
        'arbitrary_post_field', 
        $data['arbitrary_post_field'];

    return $this;
}

Alternatively, you can rewrite Mage_Sales_Model_Quote_Payment::importData() and Mage_Checkout_Model_Type_Onepage::savePayment, which gives you more flexibility, as these methods will be called before Magento selects your specific payment method based on the payment code.

从﹋此江山别 2024-09-12 00:13:47

查看单页结帐,从结帐页面上的 payment[] 表单元素检索付款数据,如下所示:

$data = $this->getRequest()->getPost('payment', array());
$result = $this->getOnepage()->savePayment($data);

该信息使用以下方式保存到实际付款中:

$payment->importData($data);

这意味着以这种方式导入的字段应该是可用于模块的 authorize() 方法,此时您可以检索正确的信息来进行身份验证。

我希望这是有道理的。如果没有,请发布表单的 HTML 以及模块中的 authorize() 方法。

谢谢,

Looking at the onepage checkout, payment data is retrieved from the payment[] form elements on the checkout page like this:

$data = $this->getRequest()->getPost('payment', array());
$result = $this->getOnepage()->savePayment($data);

That info gets saved into an actual payment using:

$payment->importData($data);

That means that fields imported this way should be available to your module's authorize() method, at which point you can go retrieve the right information to do the auth.

I hope that made sense. If not, post the HTML for the form as well as your authorize() method in the module.

Thanks,
Joe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文