0

サードパーティのチェックアウト PayPal オプションに「カスタム」値を追加しようとしています。私が抱えている問題は、PHP変数が画面に表示されていることです。セッション変数でショッピング カートの値を渡しています。

if(isset($_SESSION['checkout'])){
$orderData = '<table border="1"><th style="width:80px">Item</th>
             <th sytle="width:250px">Size</th>
             <th style="width:60px">Quantity</th>';
for ($i=0; $i<count($_SESSION['checkout']); $i++){
    $orderData .= '<tr><td style="text-align:center">'.$_SESSION['checkout'][$i][0].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][1].'</td><td style="text-align:center">'.$_SESSION['checkout'][$i][2].'</td></tr>';
}
}

そのテーブルを渡してもらいたいのですが、 PayPal のドキュメントに基づいて、それを含めるだけで済みます。次のように PayPal フォームをエコーアウトしています。

echo '<form>
      //other hidden values
      <input type="hidden" name="custom" value="'.$orderData.'">
      //input submit button here
      </form>

そして、私が言ったように、入力は非表示にすることになっていますが、PayPal ボタンの前に表示されます。どうして?

更新:これらのコードは金額を完全に渡します:

<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION['disc'])){print_r($_SESSION['disc']);}?><?php echo '">

ページには表示されませんが、変数の量はページ ソースで正しいです。

UPDATE2: カート スクリプト全体を次に示します。

echo '<div style="position:absolute; left:770px; top:50px">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemail@example.com">
<input type="hidden" name="item_name" value="Merchandise">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="custom" value="'.$orderData.'">
<input type="hidden" name="return" value="backtomywebsite.com">
<input type="hidden" name="cancel_return" value="backtomywebsite.com">
<input type="hidden" name="amount" value="';?><?php if(isset($_SESSION[$disc])){print_r($_SESSION[$disc]);}?><?php echo '">
<input type="image" src="http://www.mywebsite.com/images/BuyNow.png" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!" width="300" height="204">
    </form>
    </div>';

スクリプトは、$orderData の代わりに商品情報を含む print_r セッションがある場合に機能します。その情報は私のペイパル アカウントに送信されますが、配列形式になっており、見栄えが悪くなります。なんでも(会員情報、注文情報)phpの変数にしてカスタムフィールドに渡す方法があればいいのですが。とにかく...画面には次のように表示されます。

PayPal テキストを示す画像

今後ともよろしくお願いいたします。

4

1 に答える 1