Flutter 与 Revolut 支付的集成

问题描述 投票:0回答:1

使用此文档docs,我正在尝试将Revoult支付与Flutter集成。

但是我遇到了这些错误:

  1. 未解决的参考:RevolutPayEnvironment

  2. 未解决的参考:RevolutPayments

在我的“MainActivity.kt”中

我的 Kotlin 代码:

package com.example.foodbourge_mobile_app

import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.content.IntentFilter
import android.os.BatteryManager
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES

class MainActivity: FlutterActivity() {
  private val CHANNEL = "samples.flutter.dev/revolut_pay"

  override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
    super.configureFlutterEngine(flutterEngine)
    fun getBatteryLevel(): Int {
      val batteryLevel: Int
      if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        val batteryManager = getSystemService(Context.BATTERY_SERVICE) as BatteryManager
        batteryLevel = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
      } else {
        val intent = ContextWrapper(applicationContext).registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
        batteryLevel = intent!!.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100 / intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
      }

      return batteryLevel
    }
    fun payByRevolut(): Int {
      RevolutPayments.revolutPay.init(
            environment = RevolutPayEnvironment.SANDBOX, // Change to MAIN for production
            merchantPublicKey = "10ccaaa5-9316-44e9-9da1-2e714c3310c0",
            requestShipping = false,
            // customer = Customer(
            //     name = "John Doe",
            //     email = "[email protected]",
            //     phoneNumber = "1234567890",
            //     dateOfBirth = "1990-01-01"
            // )
        )

      return 0
    }
    MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
      call, result ->   
      if (call.method == "getBatteryLevel") {
        val batteryLevel = getBatteryLevel()

        if (batteryLevel != -1) {
          result.success(batteryLevel)
        } else {
          result.error("UNAVAILABLE", "Battery level not available.", null)
        }
      } else {
        result.notImplemented()
      }
    }
  }
}

我已经添加了:

implementation "com.revolut:revolutpayments:1.0.0"

implementation "com.revolut:revolutpay:2.2"

在我的 Android 级别 build.gradle 中。

我错过了进口吗?

请帮助我。

flutter payment
1个回答
0
投票

构建.gradle

kotlinOptions { jvmTarget = '1.8' }

buildFeatures { viewBinding true }

© www.soinside.com 2019 - 2024. All rights reserved.