PayPal沙盒API不允许买家登录

我正在开发移动应用程序的android studio。我具有付款功能,并且集成了PayPal沙箱,当用户单击时,出现PayPal页面。但是,当任何买家尝试使用显示的页面登录时,“用户名/密码错误。请重试”,尽管我确定这是正确的,并尝试了多个帐户,其中一个拥有有效的真实信用卡,但输出相同。我不知道为什么会这样?请有人能尽快帮助我。

这是用户尝试登录时出现的内容: screen shot of PayPal error message

提供了与付款部分相关的三个Java类:

confirmOrder.java:

package com.example.my1stapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatactivity;

import android.app.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
import android.content.Intent;
import com.example.my1stapplication.config.Config;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.paypal.android.sdk.payments.PayPalConfiguration;
import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalPaymentDetails;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.Paymentactivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;

import android.text.TextUtils;
import android.widget.Toast;

import org.json.JSONException;

import java.io.Serializable;

import java.util.HashMap;
import java.math.BigDecimal;

public class confirmOrder extends AppCompatactivity {

    EditText district,streetName,houseNo,phoneNo;
    Button checkout;

    DatabaseReference ordersref= FirebaseDatabase.getInstance().getReference("Orders");
    final HashMap<String,Object> ordersMap=new HashMap<>();
public static final int PAYPAL_REQUEST_CODE=7171;

private static PayPalConfiguration config = new PayPalConfiguration().environment(PayPalConfiguration.ENVironMENT_SANDBOX).clientId(Config.PAYPAL_CLIENT_ID);
 //Double totalPrice=getIntent().getDoubleExtra("totalPrice",0);


    @Override
    protected void onDestroy() {
        stopService(new Intent(this,PayPalService.class));
        super.onDestroy();
    }

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

        Double totalPrice=getIntent().getDoubleExtra("totalPrice",0);

        Intent intent = new Intent(this,PayPalService.class);
        intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION,config);
        startService(intent);

        district = (EditText) findViewById(R.id.district);
        streetName = (EditText) findViewById(R.id.streetName);
        houseNo = (EditText) findViewById(R.id.houseNo);
        phoneNo = (EditText) findViewById(R.id.phoneNo);
        checkout = (Button) findViewById(R.id.checkout);
        String buyerID = getIntent().getStringExtra("buyerID");
        // Double totalPrice=getIntent().getDoubleExtra("totalPrice",0);
        //HashMap cart=(HashMap) getIntent().getSerializableExtra("cart");


        checkout.setOnClicklistener(new View.OnClicklistener() {
            @Override
            public void onClick(View v) {

                String district1 = district.getText().toString();
                String streetName1 = district.getText().toString();
                String houseNo1 = district.getText().toString();
                String phoneNo1 = district.getText().toString();

                if (!TextUtils.isEmpty(district1) && !TextUtils.isEmpty(district1)
                        && !TextUtils.isEmpty(district1) && !TextUtils.isEmpty(district1)) {

                    Double totalPrice = getIntent().getDoubleExtra("totalPrice",0);
                    HashMap<String,Object> cart = (HashMap<String,Object>) getIntent().getSerializableExtra("cart");
                    String Orderid = ordersref.push().getKey();
                    ordersMap.put("orderID",Orderid);
                    ordersMap.put("totalPrice",(totalPrice));
                    ordersMap.put("buyerID",FirebaseAuth.getInstance().getcurrentUser().getUid());
                    ordersMap.put("district",district1);
                    ordersMap.put("streetName",streetName1);
                    ordersMap.put("houseNo",houseNo1);
                    ordersMap.put("phoneNo",phoneNo1);
                    ordersMap.put("paied",false);
                    ordersMap.put("shipped",false);
                    ordersMap.put("takenFromOwner",false);
                    //ordersMap.put("inCart",adapter);
                    ordersref.child(Orderid).updateChildren(ordersMap);
                    ordersref.child(Orderid).child("cart").updateChildren(cart);

                    processpayment();


                } else {
                    Toast.makeText(getapplicationContext(),"please enter all fields",Toast.LENGTH_LONG).show();
                }
            }

        });

    }

    private void processpayment(){

        Double totalPrice=getIntent().getDoubleExtra("totalPrice",0);
        PayPalPayment payPalPayment =new PayPalPayment(new BigDecimal(totalPrice),"USD","Pay for the material/s",PayPalPayment.PAYMENT_INTENT_SALE);


        Intent intent = new Intent(this,Paymentactivity.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION,config);
    intent.putExtra(Paymentactivity.EXTRA_PAYMENT,payPalPayment);
    startactivityForResult(intent,PAYPAL_REQUEST_CODE);


    }

    @Override
    protected void onactivityResult(int requestCode,int resultCode,@Nullable Intent data) {
        Double totalPrice=getIntent().getDoubleExtra("totalPrice",0);


        super.onactivityResult(requestCode,resultCode,data);
        if (requestCode == PAYPAL_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {

                PaymentConfirmation confirmation = data.getParcelableExtra(Paymentactivity.EXTRA_RESULT_CONFIRMATION);
                if (confirmation != null) {

                    try {

                        String paymentDetails = confirmation.toJSONObject().toString(4);
                        startactivity(new Intent(this,PaymentDetails.class).putExtra("PaymentDetails",paymentDetails).putExtra("PaymentAmount",totalPrice));
                    } catch (JSONException e) {
                        e.printStackTrace();


                    }

                } else if (resultCode == activity.RESULT_CANCELED) {
                    Toast.makeText(this,"Cancel",Toast.LENGTH_SHORT).show();
                }


            } else if (resultCode == Paymentactivity.RESULT_EXTRAS_INVALID) {
                Toast.makeText(this,"Invalid Payment",Toast.LENGTH_SHORT).show();


            }

        }


    }
}


PaymentDetails.java:


package com.example.my1stapplication;

import androidx.appcompat.app.AppCompatactivity;

import android.os.Bundle;
import android.widget.TextView;
import org.json.JSONObject;
import android.content.Intent;
import org.json.JSONException;
public class PaymentDetails extends AppCompatactivity {


    TextView txtId,txtAmount,txtStatus;

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


        txtId = (TextView)findViewById(R.id.txtId);
        txtStatus = (TextView)findViewById(R.id.txtStatus);
        txtAmount = (TextView)findViewById(R.id.txtAmount);

        Intent intent=getIntent();

        try{

            JSONObject jsonObject = new JSONObject(intent.getStringExtra("PaymentDetails"));
        showDetails(jsonObject.getJSONObject("response"),intent.getStringExtra("PaymentAmount"));



        }
        catch (JSONException e){
e.printStackTrace();


        }
    }


    private void showDetails(JSONObject response,String paymentAmount) throws JSONException {

try {
    txtId.setText(response.getString("id"));
    txtStatus.setText(response.getString("status"));
    txtAmount.setText("SR"+paymentAmount);
}

catch(JSONException e){
    e.printStackTrace();
}
    }

}

Config.java:


package com.example.my1stapplication.config;

public class Config {
    public static final String PAYPAL_CLIENT_ID = "AR1bLXBzCYYWa4BCkEyTTcbijrtWPh9u15b3sxQbHQZ-ymheonDq9zwMo1CqqM95fwHPp-pNjbRF99Am";
}
lhb000 回答:PayPal沙盒API不允许买家登录

要登录“贝宝沙盒”页面,必须使用贝宝沙盒(www.sandbox.paypal.com)帐户,而不要使用真实(www.paypal.com)帐户。

您可以在https://www.paypal.com/signin?returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts内根据需要创建任意数量的PayPal沙箱帐户

他们的电子邮件标识符是虚构的,可以是沙盒中以前未使用的任何标识符。从来没有真正的电子邮件发送到这些地址;而是在developer.paypal.com左侧有一个“通知”标签

本文链接:https://www.f2er.com/3164473.html

大家都在问