2016-06-19 62 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