現在、フォームに次のコードがあります。
<form action="https://www.paypal.com/cgi-bin/webscr" target="_BLANK" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paypal@********.com">
<input type="hidden" name="lc" value="SE">
<input type="hidden" name="item_name" value="Premium Membership">
<input type="hidden" name="custom" value="<?php echo $session_user_id; ?>">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="0.80">
<input type="hidden" name="currency_code" value="SEK">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="http://*******.com/eta/ipn.php">
<input type="hidden" name="return" value="http://********.com/purchase/thanks">
<input type="hidden" name="cancel_return" value="http://*******.com">
<input type="hidden" name="rm" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
しかし、問題は、これらの値を取得し、他のファイルにいくつかの変更を加えてから、おそらく PHP を使用してフォームを作成して送信するフォーム内アクションに移動する必要があることです (私の場合、JavaScript はオプションではありません) functions.php
。https://www.paypal.com/cgi-bin/webscr
だから、代わりに:
<form action="https://www.paypal.com/cgi-bin/webscr" target="_BLANK" method="post">
私は持っています:
<form role="sendit" method="POST">
次のように、functions.php (Wordpress を使用しています) のコードによって送信された場合に取得されます。
if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) {
// grab values from hidden input fields
$pp_cmd = $_POST['cmd'];
$pp_business = $_POST['business'];
...
// do some internal wordpress stuff with grabbed data for statistical purposes etc.
// and after that redirect using <form action="https://www.paypal.com/cgi-bin/webscr" target="_BLANK" method="post">
// probably to recreate the form and submit it using php and stay on PayPal site
??? what code here ???
}
functions.php の投稿から値を取得し、たとえば のような変数に格納できます$pp_cmd, $pp_business
。問題は、これらすべての変数を何らかの形で使用し、それらを非表示の入力として送信し、フォーム ポスト メソッドとして送信し、action="https://www.paypal.com/cgi-bin/webscr"
そのページにとどまって、PayPal ページへのアクションでデフォルト フォームを使用するかのようにする必要があることです。
どうやってするか?
ストレートPHPまたはcURLを使用したPHPを介してそれを行うことができますか? はいの場合、少なくとも最初の 2 つの隠し入力を含む基本的なコードを提供していただけますか?
更新: AJAX を使用することは、私の立場ではオプションではありません。スクリプトは、JavaScript を使用しなくても機能する必要があります。この問題の PHP ソリューションを探しています。