Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法通过开发者用户名密码登录paypal_Android_Paypal_Payment Gateway - Fatal编程技术网

Android 无法通过开发者用户名密码登录paypal

Android 无法通过开发者用户名密码登录paypal,android,paypal,payment-gateway,Android,Paypal,Payment Gateway,我在Paypal中创建了帐户,并下载了Paypal sdk。我已经提出了申请,并从网站上获得了客户id。现在,在集成到我的应用程序后,我无法通过开发者id登录Paypal网关 请帮我找出哪里出了问题 我的代码 try{ Double amount=Double.parseDouble(amnt.getText().toString()); if(amount>=62 && amount!=null && amount!=0.0){

我在Paypal中创建了帐户,并下载了Paypal sdk。我已经提出了申请,并从网站上获得了客户id。现在,在集成到我的应用程序后,我无法通过开发者id登录Paypal网关

请帮我找出哪里出了问题

我的代码

    try{
    Double amount=Double.parseDouble(amnt.getText().toString());
    if(amount>=62 && amount!=null && amount!=0.0){
    amount=amount/62;
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(""+amount), "USD", "Cab Rent");        
    Intent intent = new Intent(this, PaymentActivity.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    // It's important to repeat the clientId here so that the SDK has it if Android restarts your 
    // app midway through the payment UI flow.
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "AXJjcRB6yUtJghGBgdDHmOgkL8a9Jnd0RVARU9XPGqZ_lSstEhDSkh7D9AL2");
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "");//from ui we have to design
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

    startActivityForResult(intent, 0);
        }
        else{
            Toast.makeText(getApplicationContext(), " An invalid payment was submitted. 1$ minimum", Toast.LENGTH_LONG).show();
        }}
    catch(Exception e){
        Log.d("Paypal_Activity", ""+e); //BLUE

    }
论活动结果

   @Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
        if (confirm != null) {
            try {
                Log.i("paymentExample", confirm.toJSONObject().toString(4));

                // TODO: send 'confirm' to your server for verification.
                // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                // for more details.

            } catch (JSONException e) {
                Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
            }
        }
    }
    else if (resultCode == Activity.RESULT_CANCELED) {
        Log.i("paymentExample", "The user canceled.");
    }
    else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
        Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
    }
}

从本页开始:

PayPal错误589023尤其具有以下含义:

If a fractional amount is rounded due to currency conversion, funds could be lost
也许您没有将货币的最小单位或美分进行上/下舍入

例如:

(amount* fee_multiplier).round(2)
更新: 像$1.1和$1.111这样的值是贝宝无法接受的。我们需要确保thingToBuy中收到的值已四舍五入到最接近的美分和货币的最低单位

另一个例子:

DecimalFormat df = new DecimalFormat("#.00");
df.format(amount);
结果:

amount: 1.3333333 (double) -> df.format: 1.33 (new DecimalFormat)

像印尼盾(IDR)这样的货币没有任何小数,因为它们的最小单位是IDR 25

嘿,这是我的工作代码和我的应用程序的给定凭证

BuyActivity.java

package com.example.paypalintegration;

import java.math.BigDecimal;

import org.json.JSONException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;

public class BuyActivity extends Activity {

    private static final String CONFIG_ENVIRONMENT = PaymentActivity.ENVIRONMENT_NO_NETWORK;
    private static final String CONFIG_CLIENT_ID = "AFcWxV21C7fd0v3bYYYRCpSSRl31AR.aAFjBsPf7PzEUNdhcCM3xDQBN";
    private static final String CONFIG_RECEIVER_EMAIL = "claudia.burnett-facilitator@pushnd.com";
    private EditText amnt; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_buy);
        amnt=(EditText)findViewById(R.id.editText1);
        Intent intent = new Intent(this, PayPalService.class);

        intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
        intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
        intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

        startService(intent);
    }

    public void onBuyPressed(View pressed) {
        Double amount=Double.parseDouble(amnt.getText().toString());
        if(amount>=62 && amount!=null && amount!=0.0){
        amount=amount/62;
        }
        PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(String.valueOf(amount)), "NOK","Cab Rent");

        Intent intent = new Intent(this, PaymentActivity.class);

        intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
        intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
        intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
        intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

        startActivityForResult(intent, 0);
    }

    @Override
    protected void onActivityResult (int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i("paymentExample", confirm.toJSONObject().toString(4));

                    // TODO: send 'confirm' to your server for verification.
                    // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                    // for more details.
                    Toast.makeText(this,confirm.toJSONObject().toString(4),Toast.LENGTH_LONG).show();
                } catch (JSONException e) {
                    Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        }
        else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("paymentExample", "The user canceled.");
            Toast.makeText(this,"The user canceled.",Toast.LENGTH_LONG).show();
        }
        else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
            Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
            Toast.makeText(this,"An invalid payment was submitted. Please see the docs.",Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void onDestroy() {
        stopService(new Intent(this, PayPalService.class));
        super.onDestroy();
    }
}
XML文件activity_buy.XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/buyItBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:onClick="onBuyPressed"
        android:text="Buy this product" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="147dp"
        android:ems="10"
        android:inputType="number" >

        <requestFocus />
    </EditText>

</RelativeLayout>

and the Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.paypalintegration"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".BuyActivity"
            android:label="@string/title_activity_pay_pal_integration" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name="com.paypal.android.sdk.payments.PayPalService"
            android:exported="false" />

        <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
        <activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
        <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
        <activity
            android:name="io.card.payment.CardIOActivity"
            android:configChanges="keyboardHidden|orientation" />
        <activity android:name="io.card.payment.DataEntryActivity" />
    </application>

</manifest>

以及Manifest.xml

早些时候(8个月前)我使用了相同的代码,交易成功完成您是否尝试过在发送到paypal之前显示真实金额?Paypal不接受12.909美元这样的价格。沙盒模式测试的CVV是多少?@ManishYadav是的。1挪威克朗/1挪威克朗兑美元=0.17美元。贝宝无法接受1.1美元和1.111美元这样的价值。我们需要确保thingToBuy中收到的值已四舍五入到最接近的美分和货币的最低单位。示例:
DecimalFormat df=new DecimalFormat(“#.00”)
df.格式(金额)
金额:1.3333333(双)->df.格式:1.33
。印尼盾(IDR)等货币没有小数,因为它们的最小单位是25印尼盾。看起来您使用的不是当前版本的SDK。我建议您这样做(对您的集成稍作更改)。