2012-03-16 5 views
1

私はモバイルエクスプレスチェックアウトライブラリでお支払い方法を検討しています。私はペイパルのログインページをリダイレクトするためのURLといくつかの混乱を覚えました。そして、リンクの下で私はすでに使用しています。Android:モバイルエクスプレスチェックアウトライブラリ

1 - Sandbox.Paypal.comそれは私にログインページを与え、カード方式で支払うことはできません。そして、もし私がpaypalアカウントの手段でログインすれば、今すぐ支払うことになります。その後、このボタンメソッドは機能しません。お支払いがうまくいかない。

2 - Paypal.com私の内部サーバーエラーが発生します。ログインページも表示されません。

私の上記のリンクでは、私のトークンは、&デバイスリファレンストークンについては言及していませんでした。しかし、私はwebserviceとdevicereferenceトークンから私のトークンをpaypalリスナクラスから得ることができます。

どうすればいいですか?誰でも知っていれば私を導く?前もって感謝します。

更新

うん、私は私のウェブサービスでミスを犯し、私はその間違いをクリアして、それを修正しました。今、私は正常に私のpaypalアカウントにSandbox.Paypal.comを通じてログインすることができ、支払いが正常に転送される。私はカードの手段でのお支払いを選択した場合、それが新しいウィンドウを開き、画像の下に示すよカードでペイを使用することはできません同時に -

CardError

私はなぜ知りませんそれは起こった。私がLandingPage = Billing私のsetExpressCheckoutウェブサービスに変更した場合、私はクレジットカードページを見ることができます。そして、クレジットカードの詳細などを記入した後、支払いがうまくいかない。これは、下の画像のようなショーはよ -

Card Error

私は私がまた、クレジットカードの詳細を記入のメールアドレスを変更しました。その後、それは常にこのように表示されます。これをどうするのですか?私はそれを誤解しているのか分かりません。誰も私にこの助けてくれませんか?

重要なことは、ログインページまたはクレジットカードのページのWebビューの初めてのことです。ソフトキーボードがデバイスで動作していません。後でWebビューのどこかにコントロールがあると、それが有効になるだけです。初めてではありません。

+0

登録、ログインではありません。 – Nick

答えて

5

私は自分の問題を解決しました。 Sandbox.Paypal.com私のためにすべてが完了しました。私はMobile Express Checkout Libraryの私のウェブサービスで間違いを犯しました。支払いが成功する。

また、Pay With Cardボタンを押したときに新しいウィンドウを開く問題も解決されました。 Webビューで支払いを行うプロセス。私たちがウェブビュー手段を使用するとき、それは何かを必要としますsetWebviewClient私はこれを私のウェブビューに追加するとうまくいきます。今、私は両方のログインとpaywithカードのページを行くことができます。そして、setOnTouchListenerクラスは私のソフトキーボードを有効にします。

しかし、私はそこでクレジットカード決済を試していませんでした。ダミーのクレジットカードは受け付けません。なぜそれが受け入れられないのかわかりません。私はこれもすぐに見つけます。そして、ここでそれを更新してください。

+0

こんにちは@praveen私はpaypalでやった。しかし、今私はpaypal_MECLと置き換えます。どちらのステップを踏襲したいですか? –

3

私はpaypalで働いていませんが、このクラスをwebviewに使用する場合はWebViewClientを使用することをお勧めします。ウェブページをpaypalの両方のページにリダイレクトできます。

public class HelloWebViewClient extends WebViewClient 
{ 
public HelloWebViewClient() 
{ 
// do nothing 
} 
@Override 
public boolean shouldOverrideUrlLoading(WebView view, String url) 
{ 
view.loadUrl(url); 
return true; 
} 

@Override 
public void onPageFinished(WebView view, String url) 
{ 
// TODO Auto-generated method stub 
super.onPageFinished(view, url); 
} 
} 
+0

はい、私はここで間違います。今、私のwebviewで働いています。 – Praveenkumar

5

私はサンドボックスを通してテストするという私の問題を解決しました。私は以下のコードを添付しています。それがあなたのために働くことを願っています。

Android_PP_Test1Activity.java

package com.PageViewerTilesDemo.src; 

import java.math.BigDecimal; 

import android.app.Activity; 
import android.app.AlertDialog; 
import android.app.ProgressDialog; 
import android.content.DialogInterface; 
import android.content.DialogInterface.OnDismissListener; 
import android.content.DialogInterface.OnMultiChoiceClickListener; 
import android.content.Intent; 
import android.content.SharedPreferences; 
import android.os.Bundle; 
import android.os.Handler; 
import android.os.Message; 
import android.util.Log; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.AdapterView; 
import android.widget.AdapterView.OnItemSelectedListener; 
import android.widget.ImageView; 
import android.widget.RelativeLayout; 
import android.widget.RelativeLayout.LayoutParams; 
import android.widget.Toast; 

import com.paypal.android.MEP.CheckoutButton; 
import com.paypal.android.MEP.PayPal; 
import com.paypal.android.MEP.PayPalPayment; 

public class Android_PP_Test1Activity extends Activity implements 
    OnClickListener, OnItemSelectedListener, OnMultiChoiceClickListener, 
    OnDismissListener { 

private CheckoutButton launchPayPalButton; 
final static public int PAYPAL_BUTTON_ID = 10001; 
private static final int request = 1; 
private ProgressDialog _progressDialog; 
private boolean _paypalLibraryInit = false; 
private boolean _progressDialogRunning = false; 
private ImageView imgView; 
public static Context contex; 
public static boolean back = false; 

public static String resultTitle; 
public static String resultInfo; 
public static String resultExtra; 
private int _value = 100; // some default value that is not index 

protected static final int INITIALIZE_SUCCESS = 0; 
protected static final int INITIALIZE_FAILURE = 1; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.paypal); 
    contex = getApplicationContext(); 
    /* 
    * if (_paypalLibraryInit) { 
    * 
    * showPayPalButton(); 
    * 
    * 
    * } else { // Display a progress dialog to the user and start checking 
    * for when // the initialization is completed 
    * 
    * Thread initThread = new Thread(initLibraryRunnable); 
    * initThread.start(); 
    * 
    * _progressDialog = new ProgressDialog(Android_PP_Test1Activity.this); 
    * _progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
    * _progressDialog.setMessage("Loading PayPal Payment Library"); 
    * _progressDialog.setCancelable(false); _progressDialog.show(); 
    * _progressDialogRunning = true; Thread newThread = new 
    * Thread(checkforPayPalInitRunnable); 
    * 
    * newThread.start(); 
    * 
    * } 
    */ 

    Thread libraryInitializationThread = new Thread() { 
     public void run() { 
      initLibrary(); 

      if (PayPal.getInstance().isLibraryInitialized()) { 
       hRefresh.sendEmptyMessage(INITIALIZE_SUCCESS); 
      } else { 
       hRefresh.sendEmptyMessage(INITIALIZE_FAILURE); 
      } 
     } 
    }; 
    libraryInitializationThread.start(); 
} 

// This handler will allow us to properly update the UI. You cannot touch 
// Views from a non-UI thread. 
Handler hRefresh = new Handler() { 
    @Override 
    public void handleMessage(Message msg) { 
     Log.i("Paypal", "Inside Handler message"); 
     switch (msg.what) { 
     case INITIALIZE_SUCCESS: 
      Log.i("Paypal", 
        "Inside Handler message inside Initialize Success"); 
      showPayPalButton(); 
      break; 
     case INITIALIZE_FAILURE: 
      Log.i("Paypal", "Inside Handler message Failure"); 
      showFailure(); 
      break; 
     } 
    } 
}; 

public void showFailure() { 
    /* 
    * title.setText("FAILURE"); 
    * info.setText("Could not initialize the PayPal library."); 
    * title.setVisibility(View.VISIBLE); info.setVisibility(View.VISIBLE); 
    */ 
    Log.i("Paypal", "in Failure"); 
} 

public void showPayPalButton() { 
    Log.i("Paypal", "Inside Show Paypal Button"); 
    removePayPalButton(); 
    // Back in the UI thread -- show the "Pay with PayPal" button 
    // Generate the PayPal Checkout button and save it for later use 
    PayPal pp = PayPal.getInstance(); 
    // get the checkoutbutton 
    launchPayPalButton = pp.getCheckoutButton(
      Android_PP_Test1Activity.this, PayPal.BUTTON_194x37, 
      CheckoutButton.TEXT_PAY); 
    // add it to layout 
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
      LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
    // position this at the bottom 
    params.addRule(RelativeLayout.CENTER_IN_PARENT); 
    // some margins for visual goodness 
    params.bottomMargin = 5; 
    params.leftMargin = 50; 

    launchPayPalButton.setLayoutParams(params); 
    launchPayPalButton.setId(PAYPAL_BUTTON_ID); 
    launchPayPalButton.setOnClickListener(Android_PP_Test1Activity.this); 

    ((RelativeLayout) findViewById(R.id.RelativeLayout01)) 
      .addView(launchPayPalButton); 
} 

/* 
* this method removes the PayPal button from the view 
*/ 
private void removePayPalButton() { 
    Log.i("Paypal", "Inside removePayPalButton method"); 
    // Avoid an exception for setting a parent more than once 
    if (launchPayPalButton != null) { 
     ((RelativeLayout) findViewById(R.id.RelativeLayout01)) 
       .removeView(launchPayPalButton); 
    } 
} 

/* 
* method to handle PayPal checkout button onClick event - this must be 
* called from the onClick() method implemented by the application 
*/ 
public void PayPalButtonClick(View v) { 
    Log.i("Paypal", "Inside PayPalButtonClick method"); 
    PayPalPayment newPayment = new PayPalPayment(); 
    newPayment.setSubtotal(new BigDecimal(50)); 
    newPayment.setCurrencyType("USD"); 
    newPayment.setRecipient("[email protected]"); 
    newPayment.setMerchantName("MANTRA"); 

    Intent checkoutIntent = PayPal.getInstance().checkout(newPayment, this, 
      new ResultDelegate()); 
    // Use the android's startActivityForResult() and pass in our 
    // Intent. 
    // This will start the library. 
    /* 
    * AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    * alertDialog.setTitle("Message"); 
    * alertDialog.setMessage("You have already purchased this item!"); 
    * alertDialog.show(); 
    */ 
    this.startActivityForResult(checkoutIntent, request); 

    // Intent paypalIntent = PayPal.getInstance().checkout(newPayment, 
    // this); 
    // this.startActivityForResult(paypalIntent, 1); 

} 

/** init method **/ 
public void initLibrary() { 
    Log.i("Paypal", "Inside initLibrary method"); 
    PayPal pp = PayPal.getInstance(); 
    if (pp == null) { 
     // This is the main initialization call that takes in your Context, 
     // the Application ID, and the server you would like to connect to. 
     pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", 
       PayPal.ENV_SANDBOX); 

     // -- These are required settings. 
     pp.setLanguage("en_US"); // Sets the language for the library. 
     // -- 

     // -- These are a few of the optional settings. 
     // Sets the fees payer. If there are fees for the transaction, this 
     // person will pay for them. Possible values are FEEPAYER_SENDER, 
     // FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and 
     // FEEPAYER_SECONDARYONLY. 
     pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER); 
     // Set to true if the transaction will require shipping. 
     pp.setShippingEnabled(true); 
     // Dynamic Amount Calculation allows you to set tax and shipping 
     // amounts based on the user's shipping address. Shipping must be 
     // enabled for Dynamic Amount Calculation. This also requires you to 
     // create a class that implements PaymentAdjuster and Serializable. 
     pp.setDynamicAmountCalculationEnabled(false); 
     // -- 
     // _paypalLibraryInit = true; 

     // if dialog is running, close it 
     /* 
     * if (_progressDialog.isShowing()) { _progressDialog.dismiss(); 
     * _progressDialogRunning = false; } 
     */ 
    } 
} 

// PayPal Activity Results. This handles all the responses from the PayPal 
// Payments Library 
@Override 
public void onActivityResult(int requestCode, int resultCode, Intent intent) { 
    Log.i("Paypal", "Inside onActivityResult method"); 
    // AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    if (requestCode != request) 
     return; 
    SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", 
      MODE_WORLD_READABLE); 
    SharedPreferences.Editor prefsEditor = myPrefs.edit(); 
    Log.i("Paypal", "Inside onActivityResult method"); 
    Log.i("Paypal", " Purchase " +Firstpage.purchase); 
    if (Firstpage.purchase) { 
     prefsEditor.putString("PURCHASE", "TRUE"); 
     prefsEditor.commit(); 
     Toast.makeText(Android_PP_Test1Activity.contex, 
       "You have successfully completed your Transaction.", 
       Toast.LENGTH_LONG).show(); 
    }else{ 
     prefsEditor.putString("PURCHASE", "FALSE"); 
     prefsEditor.commit(); 
    } 


    if (back) { 
     Intent intent1 = new Intent(Android_PP_Test1Activity.this, 
       SampleTitlesDefault.class); 
     startActivity(intent1); 
     finish(); 
    } 

} 

/* 
* This method handles the PayPal Activity Results. This handles all the 
* responses from the PayPal Payments Library. This method must be called 
* from the application's onActivityResult() handler 
*/ 
public void PayPalActivityResult(int requestCode, int resultCode, 
     Intent intent) { 
    Log.i("Paypal", "Inside PayPalActivityResult method"); 
    AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    alertDialog.setTitle("Test..."); 
    alertDialog.setMessage("This is your ID " + resultCode); 
    alertDialog.show(); 

} 

/********************************** 
* PayPal library related methods 
**********************************/ 

// This lets us show the PayPal Button after the library has been 
// initialized 
final Runnable showPayPalButtonRunnable = new Runnable() { 

    public void run() { 
     showPayPalButton(); 
    } 
}; 

// This lets us run a loop to check the status of the PayPal Library init 
final Runnable checkforPayPalInitRunnable = new Runnable() { 
    public void run() { 
     checkForPayPalLibraryInit(); 
    } 
}; 

// This lets us run the initLibrary function 
final Runnable initLibraryRunnable = new Runnable() { 
    public void run() { 
     initLibrary(); 
    } 
}; 

// This method is called if the Review page is being loaded but the PayPal 
// Library is not 
// initialized yet. 
private void checkForPayPalLibraryInit() { 

    Log.i("Paypal", "Inside checkForPayPalLibraryInit method"); 

    // Loop as long as the library is not initialized 
    while (_paypalLibraryInit == false) { 
     try { 
      // wait 1/2 a second then check again 
      Thread.sleep(500); 
     } catch (InterruptedException e) { 
      // Show an error to the user 
      AlertDialog.Builder builder = new AlertDialog.Builder(this); 
      builder.setMessage("Error initializing PayPal Library") 
        .setCancelable(false) 
        .setPositiveButton("OK", 
          new DialogInterface.OnClickListener() { 
           public void onClick(DialogInterface dialog, 
             int id) { 
            // Could do anything here to handle the 
            // error 
           } 
          }); 
      AlertDialog alert = builder.create(); 
      alert.show(); 
     } 
    } 
    // If we got here, it means the library is initialized. 
    // So, add the "Pay with PayPal" button to the screen 
    runOnUiThread(showPayPalButtonRunnable); 
} 

public void onDismiss(DialogInterface dialog) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onClick(DialogInterface dialog, int which, boolean isChecked) { 
    // TODO Auto-generated method stub 

} 

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, 
     long arg3) { 
    // TODO Auto-generated method stub 

} 

public void onNothingSelected(AdapterView<?> arg0) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onClick(View v) { 
    if (v == (CheckoutButton) findViewById(PAYPAL_BUTTON_ID)) { 
     PayPalButtonClick(v); 
    } 

} 

    } 

ResultDelegateは

package com.PageViewerTilesDemo.src; 

import java.io.Serializable; 

import android.content.SharedPreferences; 
import android.util.Log; 

import com.paypal.android.MEP.PayPalResultDelegate; 

public class ResultDelegate implements PayPalResultDelegate, Serializable { 

private static final long serialVersionUID = 10001L; 


public void onPaymentSucceeded(String payKey, String paymentStatus) { 
    Log.i("Result Delegate","Inside opPaymentSucceedde"); 
    Android_PP_Test1Activity.resultTitle = "SUCCESS"; 
    Android_PP_Test1Activity.resultInfo = "You have successfully completed your transaction."; 
    Android_PP_Test1Activity.resultExtra = "Key: " + payKey; 
    Firstpage.purchase=true; 
    Android_PP_Test1Activity.back=true; 
// Toast.makeText(Android_PP_Test1Activity.contex,"You have successfully completed your transaction.", Toast.LENGTH_LONG); 
    /*Intent intent = new Intent(ResultDelegate.this, 
      SampleTitlesDefault.class); 
    startActivity(intent);*/ 
} 

public void onPaymentFailed(String paymentStatus, String correlationID,String payKey, String errorID, String errorMessage) { 
    Android_PP_Test1Activity.resultTitle = "FAILURE"; 
    Android_PP_Test1Activity.resultInfo = errorMessage; 
    Android_PP_Test1Activity.resultExtra = "Error ID: " + errorID + "\nCorrelation ID: " 
      + correlationID + "\nPay Key: " + payKey; 
    Android_PP_Test1Activity.back=true; 
} 

public void onPaymentCanceled(String paymentStatus) { 
    Android_PP_Test1Activity.resultTitle = "CANCELED"; 
    Android_PP_Test1Activity.resultInfo = "The transaction has been cancelled."; 
    Android_PP_Test1Activity.resultExtra = ""; 
    Android_PP_Test1Activity.back=true; 
} 
} 

を.javaファイル「このメールアドレスのペイパルアカウントが既にあります」などのメッセージが私はあなたが何とかように、そのデータを送っていると思います
+0

質問が表示されませんでしたか?私はすでにその方法を行っている 'モバイル決済ライブラリ'ではなく、モバイルエクスプレスチェックアウトライブラリを求めています。私に答えてくれてありがとう。 – Praveenkumar

+1

@Bhavesh hiiはクレジットカードで支払いが可能ですか? – Google

+0

@Bhavesh Patadiya現状の問題で私を助けてくれますか? – Keeano

関連する問題