为什么我收到 PayPal Android Native Checkout SDK - 无效的 client_id 或 redirect_uri

2024-04-24

我正在使用新的 Android Native Checkout SDK 和 Kotlin,并且我一直遵循文档中的每一步,但这种情况不断发生,我不知道为什么。我也在尝试PayPal Android Native Checkout SDK - 无效的 client_id 或 redirect_uri 以及 CHECKOUT_ERROR https://stackoverflow.com/questions/66380972/paypal-android-native-checkout-sdk-invalid-client-id-or-redirect-uri-and-chec但这对我不起作用。

构建.腰带:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.paypalkotlin"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation('com.paypal.checkout:android-sdk:0.2.0')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

构建腰带

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        // This private repository is required to resolve the Cardinal SDK transitive dependency.
        maven {
            url  "https://cardinalcommerceprod.jfrog.io/artifactory/android"
            credentials {
                // Be sure to add these non-sensitive credentials in order to retrieve dependencies from the private repository.
              
                username "paypal_sgerritz"
                password "AKCp8jQ8tAahqpT5JjZ4FRP2mW7GMoFZ674kGqHmupTesKeAY2G8NcmPKLuTxTGkKjDLRzDUQ"
            }
        }

    }
}


task clean(type: Delete) {
    delete rootProject.buildDir
}

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.paypalkotlin">
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.PaypalKotlin">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

layout

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.paypal.checkout.paymentbutton.PayPalButton
        android:id="@+id/payPalButton"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Activity

package com.example.paypalkotlin

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log

import com.paypal.checkout.PayPalCheckout
import com.paypal.checkout.approve.OnApprove
import com.paypal.checkout.config.CheckoutConfig
import com.paypal.checkout.config.Environment
import com.paypal.checkout.config.SettingsConfig
import com.paypal.checkout.createorder.CreateOrder
import com.paypal.checkout.createorder.CurrencyCode
import com.paypal.checkout.createorder.OrderIntent
import com.paypal.checkout.createorder.UserAction
import com.paypal.checkout.order.Amount
import com.paypal.checkout.order.AppContext
import com.paypal.checkout.order.Order
import com.paypal.checkout.order.PurchaseUnit
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    val YOUR_CLIENT_ID = "AVxCKg9vnFKxNXLU5LLylEOnGCnsG8UiN300FlmY37zI4oKdrpyiuR_zutUn77rKSVxC377x0jM_uCPk";
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val config = CheckoutConfig(
                application = application,
                clientId = YOUR_CLIENT_ID,
                environment = Environment.SANDBOX,
                returnUrl = "${BuildConfig.APPLICATION_ID}://paypalpay",
                currencyCode = CurrencyCode.USD,
                userAction = UserAction.PAY_NOW,
                settingsConfig = SettingsConfig(
                        loggingEnabled = true
                )
        )

        PayPalCheckout.setConfig(config)
        payPalButton.setup(
                createOrder = CreateOrder { createOrderActions ->
                    val order = Order(
                            intent = OrderIntent.CAPTURE,
                            appContext = AppContext(
                                    userAction = UserAction.PAY_NOW
                            ),
                            purchaseUnitList = listOf(
                                    PurchaseUnit(
                                            amount = Amount(
                                                    currencyCode = CurrencyCode.USD,
                                                    value = "10.00"
                                            )
                                    )
                            )
                    )
                    createOrderActions.create(order)
                },

                onApprove = OnApprove { approval ->
                    approval.orderActions.capture { captureOrderResult ->
                        Log.i("CaptureOrder", "CaptureOrderResult: $captureOrderResult")
                    }
                }
        )

    }

}


确保您已在 Paypal 开发者网站中添加相同的返回 URL。并且返回 URL 必须是“您的应用程序 ID”+“://paypalpay”:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么我收到 PayPal Android Native Checkout SDK - 无效的 client_id 或 redirect_uri 的相关文章

随机推荐

  • 比较sql server中两个字符串中的数字

    我有两个字符串作为 CountryLocationIDs 和 LocationIDs 其值 CountryLocationIDs 400 600 150 850 160 250 LocationIDs1 600 150 900 然后我需要另
  • 如何为特定用户选择最后一行?

    我有一个这样的表 requests id id user unix time 1 2353 1339412843 2 2353 1339412864 3 5462 1339412894 4 3422 1339412899 5 3422 13
  • 我的 Rails 路由应该是什么样子才能与 pushState Ember.js 路由一起使用?

    简而言之 当构建 Ember js 应用程序以持久保存到 Rails 应用程序时 我应该如何处理 Rails 路由 视图 我想我只需要 Rails 来渲染 application html erb 布局 以便 Ember js 应用程序初始
  • 如何修复 Chrome 扩展程序“未捕获的引用错误:文档未定义”错误? [复制]

    这个问题在这里已经有答案了 我正在创建一个扩展 我希望它能够在任何网站上找到特定的单词并突出显示它们 但是 在加载扩展程序后 我立即收到一条错误消息 有谁知道如何解决这一问题 我的代码如下 背景 js chrome runtime onIn
  • ffmpeg drawtext如何设置从右到左的方向

    i write arabic text to videos and it works fine but the issue is that the arabic language is written from right to left
  • 使用 MinMax 和 Alpha-Beta 剪枝找到最佳移动

    我正在为游戏开发 AI 我想使用MinMax算法与Alpha Beta 修剪 我对它的工作原理有一个粗略的了解 但我仍然无法从头开始编写代码 所以我花了两天的时间在网上寻找某种伪代码 我的问题是 我在网上找到的每个伪代码似乎都是基于寻找最佳
  • 属于主键?

    我有一个像这样的数据库布局 Users id name etc Lead id initials etc 基本上一个用户有很多线索 这initials字段映射到name用户表中的字段 我对用户设置有一个完美的关系 has many lead
  • 在编译时将多个文件中的变量收集到单个连续的内存块中

    我想在多个 c 文件中定义 并初始化 结构体的多个实例 但我希望它们在编译时收集到一个连续的数组中 我一直在研究使用自定义部分并使用该部分的开始和结束地址作为结构数组的开始和结束 但我还没有完全弄清楚细节 而且我不想编写自定义部分链接器脚本
  • vim:无法加载库 libpython

    我不让 vim 与 python 支持一起工作 我使用以下配置编译 vim 7 4 972 configure enable shared with features huge enable multibyte enable cscope
  • 如何使用 mediaelement.js 获取 HTML5 音频播放列表?

    我尝试在 mediaelement js 中搜索音频播放列表的示例 但我没有找到 mediaelement js 支持音频播放列表吗 如果是这样 请支持我的示例代码或链接 非常感谢 我设法获得了一个超级基本 阅读 hacky 的播放列表演示
  • WAMP服务器将MySQL切换为MariaDB

    如何在WAMP 3 1 0中将数据库从MySQL切换到MariaDB 我正在寻找它 但我找不到它 从您显示的图像来看 MySQL 和 MariaDB 似乎都已经在运行 注意 这有点占用内存 简单测试看看 MySQL 和 MariaDB 是否
  • python服务器中进程之间共享列表

    我有简单的UDP服务器 它适用于多重处理 我想创建一个列表 其中包含有关所有客户的信息 I use Manager 但我不明白 如何在列表中附加信息 我需要传输 Manager 的对象来处理 但是如何 我使用新属性的方法不起作用 impor
  • 将图像插入 JTable

    我在将图像插入 JTable 时遇到问题 我搜索了一下 发现有两种方法 您可以覆盖表模型的 getcolumnclass 或创建自定义 tablecellrender 我选择使用以下代码制作自己的单元格渲染器 public class My
  • 从 Helm stable/cert-manager 升级到 jetstack/cert-manager

    我们有一个生产 AKS 集群 其中包含stable cert manager安装 helm 图表以允许使用 Let s Encrypt 证书 当前安装的版本是cert manager v0 6 0 in the kube system命名空
  • Laravel:BadMethodCallException 方法 [find] 不存在

    当尝试使用模型对象 User 从数据库中提取一些值时 出现以下错误 BadMethodCallException Method find does not exist 这是我的文件 模范用户
  • 错误 NU5049 不支持 SDK 样式项目的 pack 命令

    我的解决方案包含 Framework 4 8 项目 Net Standard 2 1 项目和 net6 项目 它已经运行了几周 没有出现任何问题 今天构建管道开始失败并出现错误 错误 nuget 命令失败 退出代码 1 和错误 错误 NU5
  • 解析iOS SDK:从Xcode调用云函数

    Scenario我想在我的应用程序中使用这两个云函数 他们检查用户的在线状态 我想为每个用户设置一个布尔键 isOnline 如果用户在线 则设置为 是 如果用户不在线 则设置为 否 var moment require moment Pa
  • 使用 jQuery 获取类中不同类型的输入

    假设我在 JavaScript 中有一个 jquery 函数 并且到目前为止我有这段代码 效果很好 jQuery div class someClass input type text each function some code 在上面
  • 如何在 C# 中使用随机数?

    我正在用 C 和 XNA 开发 Pong 我想使用一个随机数 在一定范围内 来确定诸如球是否直线反弹或以一定角度反弹以及球击中球拍时移动的速度之类的事情 我想知道如何实施 Use the Random http msdn microsoft
  • 为什么我收到 PayPal Android Native Checkout SDK - 无效的 client_id 或 redirect_uri

    我正在使用新的 Android Native Checkout SDK 和 Kotlin 并且我一直遵循文档中的每一步 但这种情况不断发生 我不知道为什么 我也在尝试PayPal Android Native Checkout SDK 无效