2014-02-13 37 views
1

我正在嘗試託管重複實現的表單並使用PHP創建簽名。我跟隨了文檔,搜索了示例並複製了代碼,並嘗試了我能想到的所有組合,但我無法弄清楚問題所在 - 在我的PHP頁面上,表單出現,但在頂部我看到PHP的一部分代碼而不是代碼執行。Recurly.js - PHP客戶端 - 數字簽名

我的代碼:

<?php 
require_once('/lib/recurly.php'); 

// Required for the API 
Recurly_Client::$subdomain = 'myactualsubdomain' 
Recurly_Client::$apiKey = 'removedmyapiforsecurity'; 
Recurly_js::$privateKey = 'removedmyprivatekeyforsecurity'; 

$signature = Recurly_js::sign(array(
'account'=>array('account_code'=>'aaa1234588'), 
'subscription' => array( 
'plan_code' => 'innovator', 
    'currency'=>'USD', 
    ))); 
?> 

<html lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Innovator Yearly Subscription</title> 
<html> 
    <head> 
    <link rel="stylesheet" href="/css/recurly.css" type="text/css" /> 
<script src="/js/jquery.js"></script> 
<script src="/js/recurly.js"></script> 
    <script> 
    $(function(){ 
     Recurly.config({ 
    subdomain: 'supportpay' 
    , currency: 'USD' // GBP | CAD | EUR, etc... 
    }); 

    Recurly.buildSubscriptionForm({ 
    target: '#recurly-subscribe', 
    planCode: 'innovator', 
    successURL: 'success.php', 
    signature: '$signature', 
distinguishContactFromBillingInfo: false, 
collectCompany: false, 
collectContact: true, 
termsOfServiceURL: 'http://supportpay.com/contact/terms-of-use/', 
acceptPaypal: false, 
acceptedCards: ['mastercard', 
       'discover', 
       'american_express', 
       'visa'], 
    }); 

}); 
    </script> 
    </head> 
    <body> 
    <h1>Subscribe to Plan</h1> 
    <h2>Plan Code: Innovator - Yearly5</h2> 
    <div id="recurly-subscribe"> 
    </div> 
    </body> 
</html> 

當我使用該代碼並運行PHP的瀏覽器表單/頁正確地呈現,除了頂部有這個代碼

array('account_code'=>'aaa1234588'),'subscription' => array('plan_code' =>'innovator', 'currency'=>'USD',))); ?> 

可有人請棚我在這裏做錯了什麼?

謝謝!

+0

我是有幫助的,如果你能加入更多的結果頁面,當你渲染它。 – drewish

+0

我知道我爲時已晚,但在您嘗試執行的計算機上安裝了PHP嗎? – karthikr

回答

2

好像意味着你需要把PHP變量一個PHP標識中:

Recurly.buildSubscriptionForm({ 
    target: '#recurly-subscribe', 
    planCode: 'innovator', 
    successURL: 'success.php', 
    signature: '<?php print $signature ?>', 
    distinguishContactFromBillingInfo: false, 
    collectCompany: false, 
    collectContact: true, 
    termsOfServiceURL: 'http://supportpay.com/contact/terms-of-use/', 
    acceptPaypal: false, 
    acceptedCards: ['mastercard', 
        'discover', 
        'american_express', 
        'visa'], 
});