2013-04-18 27 views
1

我打算使用Spree購物網站,但在某些時候需要使用銀行提供的PHP程序簽署一些數據。我能想到的唯一選擇是鏈接到運行PHP程序的somePage.php並返回到Spree。有沒有更簡單的方法,比如發送到Ruby內部的某個PHP shell?或改變爲視圖有PHP擴展? 任何幫助,將不勝感激。需要在rails製作頁面內運行php程序

回答

0

那麼,首先我會檢查一種在Ruby中籤名數據的原生Ruby方式。先看一下Spree文檔,或者看看你的銀行規格(他們通常很糟糕,銀行家如何寫合同,他們不擅長編寫軟件規格)。

作爲第二種選擇,如果你有PHP程序,你應該嘗試在Ruby中翻譯它。

如果這不是一個選項,你,那麼你可以用open4這樣玩:

status = Open4::popen4("/path/to/php bank_code.php #{data_to_sign}") do |pid, stdin, stdout, stderr| 
    out_msg = stdout.read 
    err_msg = stderr.read 
    logger.error "out_msg #{out_msg}" 
    logger.error "err_msg #{err_msg}" 
end 
handle_error_case if status.existatus != 0 

乾杯,