【问题标题】:How to edit paypal activities layout如何编辑贝宝活动布局
【发布时间】:2016-03-08 09:55:50
【问题描述】:

我正在使用com.paypal.android.MEP.PayPalActivity 库。我想编辑布局,但我无法访问它。如何编辑此库的默认布局。我正在尝试将钱从一个帐户转移到另一个帐户。它工作正常,但用户界面看起来很糟糕

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.paypal.android.MEP.CheckoutButton;
import com.paypal.android.MEP.PayPal;
import com.paypal.android.MEP.PayPalActivity;
import com.paypal.android.MEP.PayPalAdvancedPayment;
import com.paypal.android.MEP.PayPalPayment;
import com.paypal.android.MEP.PayPalReceiverDetails;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import project.com.holobech.MainActivity;
import project.com.holobech.R;
import project.com.holobech.app.AppConfig;
import project.com.holobech.app.AppController;
import project.com.holobech.model.UserList;
import project.com.holobech.util.PaypalUtil;


public class PaypalActivity extends ActionBarActivity {
    // LogCat tag
    private static final String TAG = PaypalActivity.class.getSimpleName();

    public final int PAYPAL_RESPONSE = 100;
    TextView txtOdullendirEmail;
    TextView txtOdullendirAmount;

    private ProgressDialog pDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paypal);

        // Progress dialog
        pDialog = new ProgressDialog(this);
        pDialog.setCancelable(false);

        txtOdullendirEmail = (TextView) findViewById(R.id.txt_odullendir_email);
        txtOdullendirEmail.setText("Ödüllendirilecek E-Posta : " + ProfileFragment.email);

        txtOdullendirAmount= (TextView) findViewById(R.id.txt_odullendir_amount);
        txtOdullendirAmount.setText("Ödüllendirilecek Miktar : 1$");

        Button paypal_button = (Button) findViewById(R.id.paypal_button);

        initLibrary();
        paypal_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // pay integration here

                PayPalButtonClick(ProfileFragment.email, "1");

            }
        });

    }

    public void initLibrary() {
        PayPal pp = PayPal.getInstance();
        if (pp == null) {

            pp = PayPal.initWithAppID(this, PaypalUtil.paypal_liv_id,
                    PayPal.ENV_LIVE);

        }
    }


    public void PayPalButtonClick(String primary_id, String primary_amount) {
        // Create a basic PayPal payment

        // PayPalPayment newPayment = new PayPalPayment();
        // newPayment.setSubtotal(new BigDecimal("1.0"));
        // newPayment.setCurrencyType("USD");
        // newPayment.setRecipient("npavankumar34@gmail.com");
        // newPayment.setMerchantName("My Company");
        // Log.d("pavan", "calling intent");
        // if( PayPal.getInstance()!=null){
        // Log.d("pavan", "in if");
        // Intent paypalIntent = PayPal.getInstance().checkout(newPayment,
        // this);
        // startActivityForResult(paypalIntent, 1);
        //

        // config reciever1
        PayPalReceiverDetails receiver0;
        receiver0 = new PayPalReceiverDetails();
        receiver0.setRecipient(primary_id);
        receiver0.setSubtotal(new BigDecimal(primary_amount));

        // adding payment type
        PayPalAdvancedPayment advPayment = new PayPalAdvancedPayment();
        advPayment.setCurrencyType("TRY");



        advPayment.getReceivers().add(receiver0);
        Intent paypalIntent = PayPal.getInstance().checkout(advPayment, this);
        this.startActivityForResult(paypalIntent, PAYPAL_RESPONSE);

    }



    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        Log.d("pavan", "response");

        if (requestCode == PAYPAL_RESPONSE) {

            switch(resultCode) {
                case Activity.RESULT_OK:
                    //The payment succeeded
                    String payKey =
                            data.getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
                    Log.d("pavan", "success "+payKey);

                    Toast.makeText(getApplicationContext(), "Payment done succesfully ", Toast.LENGTH_LONG).show();

                    setMoneyTransfer();


                    break;
                case Activity.RESULT_CANCELED:
                    Toast.makeText(getApplicationContext(), "Payment Canceled , Try again ", Toast.LENGTH_LONG).show();


                    break;
                case PayPalActivity.RESULT_FAILURE:
                    Toast.makeText(getApplicationContext(), "Payment failed , Try again ", Toast.LENGTH_LONG).show();


                    break;
            }



        }

    }




    private void setMoneyTransfer() {
        // istek iptali için tag
        String tag_string_req = "req_money_transfer";

        pDialog.setMessage("Lütfen bekleyin...");
        showDialog();

        StringRequest strReq = new StringRequest(Request.Method.POST, AppConfig.URL_CONTEST, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.d(TAG, "Para transferi yanıtı : " + response.toString());
                hideDialog();

                try{
                    JSONObject jObj = new JSONObject(response);
                    boolean error = jObj.getBoolean("error");

                    // json hatası kontrolü
                    if (!error) {
                        // başarılı
                        Log.d("Response", response.toString());

                    } else {
                        // başarısız
                        String errorMsg = jObj.getString("error_msg");
                        Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    // JSON hatası
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, "Para transferi Hatası: " + error.getMessage());
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
                hideDialog();
            }
        }) {

            @Override
            protected Map<String, String> getParams() {
                // login urle bilgileri gönder
                Map<String, String> params = new HashMap<String, String>();
                params.put("tag", "money_transfer");
                params.put("sender", MainActivity.PROFILE_EMAIL);
                params.put("receiver", ProfileFragment.email);

                return params;
            }
        };

        // istek kuyruğuna isteği ekle
        AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
    }

    private void showDialog() {
        if (!pDialog.isShowing())
            pDialog.show();
    }

    private void hideDialog() {
        if (pDialog.isShowing())
            pDialog.dismiss();
    }


}

【问题讨论】:

    标签: java android paypal


    【解决方案1】:

    此结帐页面布局是默认布局,您无法编辑布局。

    【讨论】:

    • 是否有新的 paypal 布局可以从没有任何市场的账户向账户转账?
    猜你喜欢
    • 2013-02-06
    • 2022-06-11
    • 2017-09-02
    • 2013-10-05
    • 2014-03-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-29
    • 2017-11-11
    相关资源
    最近更新 更多