2016-06-19 126 views
0

如何在我的自定义模块中拦截$ _POST数据(从一个模块打印出来)?Drupal 7 Commerce Paypal IPN

我正在使用Commerce模块和PayPal在我的Drupal网站上提供付款。

我的问题是围绕我无法收到PayPal IPN交易数据。

在Drupal日志中,我找到了Commerce_checkout模块生成的$ _POST数据。该数据如下:

Array 
(
    [mc_gross] => 1.00 
    [invoice] => 42-1466371657 
    [protection_eligibility] => Ineligible 
    [item_number1] => 
    [payer_id] => 69AYKSJVPCN48 
    [tax] => 0.00 
    [payment_date] => 14:27:58 Jun 19, 2016 PDT 
    [option_selection1_1] => 1 
    [payment_status] => Completed 
    [charset] => utf-8 
    [mc_shipping] => 0.00 
    [mc_handling] => 0.00 
    [first_name] => test 
    [mc_fee] => 0.24 
    [notify_version] => 3.8 
    [custom] => 
    [payer_status] => verified 
    [business] => [email protected] 
    [num_cart_items] => 1 
    [mc_handling1] => 0.00 
    [payer_email] => [email protected] 
    [verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31AfxmnZuHUiYodjVMGelbrZ3s3Ylv 
    [mc_shipping1] => 0.00 
    [tax1] => 0.00 
    [option_name1_1] => Product count 
    [txn_id] => 10L50068V5914254J 
    [payment_type] => instant 
    [last_name] => buyer 
    [item_name1] => Order 42 at Mysite 
    [receiver_email] => [email protected] 
    [payment_fee] => 
    [quantity1] => 1 
    [receiver_id] => BGEFKZZCD22XA 
    [txn_type] => cart 
    [mc_gross_1] => 1.00 
    [mc_currency] => GBP 
    [residence_country] => GB 
    [test_ipn] => 1 
    [transaction_subject] => 
    [payment_gross] => 
    [auth] => AT2Z0IOHTJopgBP2XkLyQCQ8L2lhYfZUxhpmutbdOyy-ZqV7HolIN2nSv2Tl4shPAi77wEUvDTmNKAfewbCZ83Q 
) 

即输出从下面的代码:

function commerce_paypal_wps_redirect_form_validate($order, $payment_method) { 
    if (!empty($payment_method['settings']['ipn_logging']) && 
    $payment_method['settings']['ipn_logging'] == 'full_ipn') { 
    watchdog('commerce_paypal_wps', 'Customer returned from PayPal with the following POST data:!ipn_data', array('!ipn_data' => '<pre>' . check_plain(print_r($_POST, TRUE)) . '</pre>'), WATCHDOG_NOTICE); 
    } 

我的问题是,我需要访问相同的数据,但是从一个自定义模块。

我实现hook_redirect_form,在我试图挖掘并访问$ _ POST数据hook_form_validate但都没有成功。

任何人都可以用正确的方法指导我解决这个难题吗?

回答

0

您不应该尝试访问$ _POST变量,这不是最佳实践。 因此,您应该能够访问hook_submit_form中的数据,尝试通过钩子定义安装Devel和DSM()所有您有权访问的变量,您可能会发现所查找的内容。 Cheers Denis