2017-10-20 21 views
0

私は支払い方法Paypalのボタンを実装しようとしています。だから私はウェブサイトのguideに従ったかったのです。私はJavaとPlayフレームワーク2.6を使用しています。PlayフレームワークJava 2.6でPaypalボタンを追加

彼らは独自のコードに追加するには、ウェブサイト上で、次のコードを与える:

<!DOCTYPE html> 

<head> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<script src="https://www.paypalobjects.com/api/checkout.js"></script> 
</head> 

<body> 
<div id="paypal-button"></div> 

    <script> 
    paypal.Button.render({ 

     env: 'production', // Or 'sandbox', 

     commit: true, // Show a 'Pay Now' button 

     payment: function() { 
      // Set up the payment here 
     }, 

     onAuthorize: function(data, actions) { 
      // Execute the payment here 
     } 

    }, '#paypal-button'); 
    </script> 
</body> 

私は頭のために(main.scala.htmlと呼ばれる)別のファイルを持っているので私のコードは少し異なっています。したがって、このような主なルックス:

@* 
* This template is called from the `index` template. This template 
* handles the rendering of the page header and body tags. It takes 
* two arguments, a `String` for the title of the page and an `Html` 
* object to insert into the body of the page. 
*@ 
@(title: String)(content: Html) 

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <!-- These are the meta and scripts for paypal--> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script> 


     @* Here's where we render the page title `String`. *@ 
     <title>@title</title> 

      <!-- Loading third party fonts --> 
      <link href="@routes.Assets.versioned("fonts/another_font.css")" rel="stylesheet" type="text/css"> 

     <!-- Loading weather css file --> 
     <link rel="stylesheet" href="@routes.Assets.versioned("stylesheets/bootstrap.css")"> 
     <link rel="stylesheet" href="@routes.Assets.versioned("stylesheets/weather.css")"> 

     <link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")"> 

     <script src="@routes.Assets.versioned("javascripts/jquery-3.2.1.min.js")" type="text/javascript"></script> 
     <script src="@routes.Assets.versioned("javascripts/bootstrap.js")" type="text/javascript"></script> 

    </head> 
    <body> 
     @* And here's where we render the `Html` object containing 
     * the page content. *@ 
     @content 
    </body> 
</html> 

はボディのために主に呼び出されるコンテンツは次のようになります。メインファイルで

@main("ReStart") { 
    <body> 
      <!-- Payment Methods --> 
         @*TODO*@ 
         <div class="col-md-9"> 
          <h2>payment methodes</h2> 
          <div id="paypal-button"></div> 

          <script> 
            paypal.button.render({ 

             env: 'production', // Or 'sandbox', 

             commit: true, // Show a 'Pay Now' button 

             payment: function() { 
              // Set up the payment here 
             }, 

             onAuthorize: function(data, actions) { 
              // Execute the payment here 
             } 

            }, '#paypal-button'); 
          </script> 
         </div> 
     <!-- Required for the banner --> 
     <script src="@routes.Assets.versioned("javascripts/jquery-1.11.1.min.js")"></script> 

     <script src="@routes.Assets.versioned("javascripts/plugins.js")"></script> 
     <script src="@routes.Assets.versioned("javascripts/app.js")"></script> 

    </body> 
} 

私は、メタおよびスクリプトへのリンクを追加しました。コンテンツファイルには、ボタンをレンダリングするための呼び出しがありますが、何らかの理由で私はそれをレンダリングできません。私が試した

もの:

checkout.jsをダウンロード
  1. を、次のスクリプトタグ

    <script src="@route.Assets.Versioned("javascript/checkout.js")"></script> 
    
  2. を使用し、私は両方のファイルに(リンクとJSダウンロードしたファイルを)スクリプトタグを試してみました。メインとコンテンツファイル。

とてもシンプルに見えますが、私はそれを理解できません。

答えて

0

あなたが書かれているコンテンツを与えているあなたのコードでは、 -

paypal.button.render 

代わりの

paypal.Button.render 

あなたが小さな使用しているのに対し、ボタンで「B」は首都である必要があります。それを修正し、それが動作するかどうかを確認してください。私が助けてくれることを願っています!

0
  1. スカラコードからHTMLスタイルコメントを削除してください。私は<! - - - - >の代わりにいくつかのスカラメソッドを使用する代わりにスカラコメント@* *@を使用します。
  2. 資本Bでpaypalボタンの初期化スクリプトを変更します。
  3. パブリックディレクトリからPaypal jsおよびcssファイルにアクセスできるかどうかを確認します。あなたはlocalhost:port/assets/rest_of_your_hierarchyからそれを行うことができます。
関連する問題