サーブレットを使用してIPNコールバックを試しています。私が使用しているコードは、ipnデータを検証するためにpaypalによって提供されています。しかし、私が無効な応答を受け取るたびに。
コードは次のとおりです。
Enumeration en = req.getParameterNames();
String str = "cmd=_notify-validate";
while (en.hasMoreElements()) {
String paramName = (String) en.nextElement();
String paramValue = req.getParameter(paramName);
//str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue,"UTF-8"); // for UTF-8 i set the encode format in my account as UTF-8
//str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue,"ISO-8859-1");// for ISO-8859-1 i set the encode format in my account as ISO-8859-1
str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue); //default as provided by paypal
}
URL u = new URL("http://www.sandbox.paypal.com/cgi-bin/webscr");
URLConnection uc = u.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
PrintWriter pw = new PrintWriter(uc.getOutputStream());
pw.println(str);
pw.close();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String res = in.readLine();
in.close();
if (res.equals("VERIFIED") || !res.equals("VERIFIED")) {
//Update database...
} else if (res.equals("INVALID")) {
//INVALID
}
ペイパルが次のように無効を返す場合に備えて、ペイパルが提供する3つの可能性すべてを確認しました。
1)欠落しているパラメーター-私はすべてのパラメーターを送信しているので、欠落しているパラメーターの問題はありません
2)無効なURL。-私はサンドボックスを使用しているので、URLは次のとおりです:http://www.sandbox.paypal.com/cgi-bin/webscr
3)文字エンコード。-ペイパルアカウント設定パラメータエンコーディングと同じ文字エンコーディングで試してみました。
次のパラメータを使用してペイパルに返送するリクエスト:
cmd = _notify-validate&last_name = User&test_ipn = 1&address_name = Test + User&txn_type = web_accept&receiver_email = Sellr1_1252495907_biz%40gmail.com&residence_country = US&address_city = San + Jose&payment_gross =&payment_date = 01%3 1 +メイン+セント&FIRST_NAME =テスト&payer_email = buyer1_1252495751_per%40gmail.com&protection_eligibility =適格&payer_id = BXBKS22JQCUWL&verify_sign = AOMkeg7ofCL7FJfioyWA19uCxD4XAgZirsjiGh8cUy1fd2YAqBwOkkst&PAYMENT_TYPE =インスタント&ビジネス= sellr1_1252495907_biz%40gmail.com&address_country_code = US&mc_fee = 0.64&address_status =確認transaction_subject =真+アップ&数量&= 1&notify_version = 2.8&mc_currency = EUR&カスタム=&address_state = CA&payment_fee = &Handling_amount = 0.00&payer_status = verified&shipping = 0.00&item_name = True + Up&tax = 0.00&username = hannonj&charset = windows-1252&item_number = 567&mc_gross = 10.00&txn_id = 7F456350BS7942738&receiver_id = MASSU6BSR9SC2&address_country = United
どうか、誰かが私を正しい方向に向けることができますか?コードやURLなどの何が間違っているのかわかりません。私はすべての可能性を試しました。私を助けてください。