Commit c8c518d2 authored by 王雪伟's avatar 王雪伟

[提交人]:王雪伟

[提交简述] :加入paypal依赖
[实现方案] :
parent f64f35b1
......@@ -127,6 +127,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
applicationVariants.all { variant ->
//这个修改输出的APK路径
......
......@@ -3,6 +3,12 @@ package com.zhangxin.magicbox
import android.app.Application
import android.text.TextUtils
import com.mob.MobSDK
import com.paypal.checkout.PayPalCheckout
import com.paypal.checkout.config.CheckoutConfig
import com.paypal.checkout.config.Environment
import com.paypal.checkout.config.SettingsConfig
import com.paypal.checkout.createorder.CurrencyCode
import com.paypal.checkout.createorder.UserAction
import com.umeng.commonsdk.UMConfigure
import com.umeng.socialize.PlatformConfig
import com.zxhl.cms.AppContext
......@@ -34,6 +40,24 @@ class Appli : Application() {
getOaid()
initByteDance()
MobSDK.init(this)
initPayPal()
}
private fun initPayPal() {
val config = CheckoutConfig(
application = this,
clientId = Constant.PAY_PAL_CLIENT_ID,
environment = Environment.SANDBOX,//正式上线后,改为Environment.LIVE
returnUrl = "com.zhangxin.magicbox://paypalpay",//创建应用时填的RETURN_URL
currencyCode = CurrencyCode.USD,//货币种类:CNY-人民币;HKD-港币;TWD-新台币;USD-美元...
userAction = UserAction.PAY_NOW,
settingsConfig = SettingsConfig(
loggingEnabled = true
)
)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
PayPalCheckout.setConfig(config)
}
}
private fun getOaid() {
......
PACKAGE_NAME=com.zhangxin.magicbox
VERSION_CODE=1
VERSION_CODE=2
VERSION_NAME=1.0.0
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.4.32'
// ext.kotlin_version = '1.6.20-RC'
repositories {
maven {
url "https://mvn.mob.com/android"
......@@ -23,6 +24,17 @@ 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'
}
}
}
}
......@@ -31,6 +43,6 @@ task clean(type: Delete) {
}
ext {
targetSdkVersion = 30
minSdkVersion = 17
minSdkVersion = 21
compileSdkVersion = 29
}
......@@ -64,8 +64,9 @@ android {
}
}
kotlinOptions {
jvmTarget = "1.8"
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
......@@ -91,13 +92,14 @@ dependencies {
api 'com.android.support:design:28.0.0'
api 'com.android.support:support-v4:28.0.0'
api 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.71'
// api 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.71'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.32"
api 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
api 'com.trello.rxlifecycle2:rxlifecycle:2.2.0'
api 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.0'
api 'com.squareup.retrofit2:retrofit:2.3.0'
api 'com.squareup.retrofit2:converter-gson:2.3.0'
api 'com.squareup.okhttp3:logging-interceptor:3.4.1'
api 'com.squareup.retrofit2:retrofit:2.9.0'
api 'com.squareup.retrofit2:converter-gson:2.9.0'
api 'com.squareup.okhttp3:logging-interceptor:4.8.1'
api 'org.jetbrains.anko:anko-common:0.9'
//友盟
api 'com.badoo.mobile:android-weak-handler:1.1'
......@@ -123,5 +125,10 @@ dependencies {
implementation(name: 'alipaySdk-15.6.4-20190611174341', ext: 'aar')
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
//GooglePay
implementation("com.android.billingclient:billing:4.1.0")
//PayPal支付
api 'com.paypal.checkout:android-sdk:0.6.0'
// api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"
// api "androidx.core:core-ktx:1.6.0"
}
package com.zxhl.cms.ad.upload.model;
import java.io.Serializable;
/**
* @Description: java类作用描述
* @Author: lidandan
* @CreateDate: 2021/12/25 10:54 上午
*/
public class Response<T> implements Serializable {
private String status = "";
private String msg = "";
private Result<T> result = null;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Result<T> getResult() {
return result;
}
public void setResult(Result<T> result) {
this.result = result;
}
public static class Result<T> implements Serializable {
private T data = null;
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
}
package com.zxhl.cms.ad.upload.model
import java.io.Serializable
/**
* Created by gaoleichao on 2018/7/13.
*/
class Response<T> {
var status: String? = ""
var msg: String? = ""
var result: Result<T>? = null
inner class Result<T> : Serializable {
var data: T? = null
}
}
......@@ -8,6 +8,9 @@ import android.Manifest;
public class Constant {
public static String PAY_PAL_CLIENT_ID ="AfYZMocYWtjeORYcG29SjvjJjS8L9_Mh8xlTi74ifLXboxFaVb43F_ZLc8geZVqLN47m2wr9PD24tRIh";
//公共参数
String UMENG_APPKEY = "597dbf2abbea835685001b27";
......
......@@ -12,17 +12,17 @@ import kotlinx.android.synthetic.main.activity_google_pay.*
class GooglePayActivity : BaseActivity() {
private val TAG = "GooglePayActivity"
private val purchasesUpdatedListener =
PurchasesUpdatedListener { billingResult, purchases ->
// To be implemented in a later section.
Log.d(TAG, "purchasesUpdatedListener" + billingResult.responseCode)
Log.d(TAG, "purchasesUpdatedListener" + purchases?.size)
}
private var billingClient = BillingClient.newBuilder(AppContext.get())
.setListener(purchasesUpdatedListener)
.enablePendingPurchases()
.build()
// private val purchasesUpdatedListener =
// PurchasesUpdatedListener { billingResult, purchases ->
// // To be implemented in a later section.
// Log.d(TAG, "purchasesUpdatedListener" + billingResult.responseCode)
// Log.d(TAG, "purchasesUpdatedListener" + purchases?.size)
// }
//
// private var billingClient = BillingClient.newBuilder(AppContext.get())
// .setListener(purchasesUpdatedListener)
// .enablePendingPurchases()
// .build()
override fun onClick(v: View?) {
......@@ -36,50 +36,50 @@ class GooglePayActivity : BaseActivity() {
id_btn_google_pay.setOnClickListener {
}
startConnection()
// GooglePayHelper(this).init()
}
fun startConnection() {
if(billingClient.isReady){
}
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
// The BillingClient is ready. You can query purchases here.
// BillingClient准备好了。你可以在这里查询购买情况。
//querySkuDetails()
querySkuDetails()
}
Log.d(TAG, billingResult.toString())
}
override fun onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// 尝试在下一次请求时重新启动连接
// Google Play by calling the startConnection() method.
// 谷歌通过调用startConnection()方法来播放。
startConnection()
Log.d(TAG, "onBillingServiceDisconnected")
}
})
}
fun querySkuDetails() {
val skuList: MutableList<String> = ArrayList()
skuList.add("premium_upgrade")
skuList.add("gas")
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(SkuType.INAPP)
billingClient.querySkuDetailsAsync(
params.build()
) { billingResult, skuDetailsList ->
// Process the result.
Log.d(TAG, "billingResult ${billingResult.responseCode}")
Log.d(TAG, "skuDetailsList ${skuDetailsList?.size}")
}
// startConnection()
GooglePayHelper(this,"").init()
}
//
//
// fun startConnection() {
// if(billingClient.isReady){
//
// }
// billingClient.startConnection(object : BillingClientStateListener {
// override fun onBillingSetupFinished(billingResult: BillingResult) {
// if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
// // The BillingClient is ready. You can query purchases here.
// // BillingClient准备好了。你可以在这里查询购买情况。
// //querySkuDetails()
// querySkuDetails()
// }
// Log.d(TAG, billingResult.toString())
// }
//
// override fun onBillingServiceDisconnected() {
// // Try to restart the connection on the next request to
// // 尝试在下一次请求时重新启动连接
// // Google Play by calling the startConnection() method.
// // 谷歌通过调用startConnection()方法来播放。
// startConnection()
// Log.d(TAG, "onBillingServiceDisconnected")
// }
// })
// }
//
// fun querySkuDetails() {
// val skuList: MutableList<String> = ArrayList()
// skuList.add("premium_upgrade")
// skuList.add("gas")
// val params = SkuDetailsParams.newBuilder()
// params.setSkusList(skuList).setType(SkuType.INAPP)
// billingClient.querySkuDetailsAsync(
// params.build()
// ) { billingResult, skuDetailsList ->
// // Process the result.
// Log.d(TAG, "billingResult ${billingResult.responseCode}")
// Log.d(TAG, "skuDetailsList ${skuDetailsList?.size}")
// }
// }
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.zxhl.cms.googlepay
import android.app.Activity
import android.util.Log
import com.android.billingclient.api.*
import com.android.billingclient.api.BillingClient.BillingResponseCode
import com.android.billingclient.api.BillingClient.SkuType
import com.zxhl.cms.AppContext
......@@ -17,7 +18,7 @@ class GooglePayHelper {
private var mActivity: Activity;
private var mSku: String = ""
constructor(mActivity: Activity,mSku:String) {
constructor(mActivity: Activity, mSku: String) {
this.mActivity = mActivity
this.mSku = mSku
}
......@@ -45,12 +46,13 @@ class GooglePayHelper {
Log.d(TAG, "init 开始连接")
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
Log.d(TAG, "init 开始连接 code:" + billingResult.responseCode)
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
//BillingClient准备好了。你可以在这里查询购买情况。
Log.d(TAG, "init 连接成功")
//查询商品购买
purchase()
}else{
Log.d(TAG, "init 连接失败 code:" + billingResult.responseCode)
}
}
......@@ -88,6 +90,28 @@ class GooglePayHelper {
Log.d(TAG, "purchase 查询失败")
}
}
}
fun handlePurchase(purchase: Purchase) {
// Purchase retrieved from BillingClient#queryPurchasesAsync or your PurchasesUpdatedListener.
// Verify the purchase.
// Ensure entitlement was not already granted for this purchaseToken.
// Grant entitlement to the user.
val consumeParams = ConsumeParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken)
.build()
val listener =
ConsumeResponseListener { billingResult, purchaseToken ->
if (billingResult.responseCode == BillingResponseCode.OK) {
// Handle the success of the consume operation.
}
}
billingClient.consumeAsync(consumeParams, listener)
}
}
\ No newline at end of file
package com.zxhl.cms.net
import android.text.TextUtils
import com.zxhl.cms.utils.PhoneUtils
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.net.api.*
import com.zxhl.cms.utils.LogUtils
import okhttp3.*
import com.zxhl.cms.utils.GsonInstance
import okhttp3.Interceptor
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
......@@ -19,9 +18,9 @@ object ApiClient {
private val logInterceptor = HttpLoggingInterceptor()
private val paramsInterceptor = Interceptor { chain ->
val request = chain.request()
val builder = request.url().newBuilder()
if (request.url().host().toString().contains("zhangxinhulian.com")) {
val builder = request.url().newBuilder()
val builder = request.url.newBuilder()
if (request.url.host.toString().contains("zhangxinhulian.com")) {
val builder = request.url.newBuilder()
PhoneUtils.addParam(request, builder)
chain.proceed(request.newBuilder().url(builder.build()).build())
} else {
......@@ -32,7 +31,7 @@ object ApiClient {
private val headInterceptor = Interceptor { chain ->
val request = chain.request()
val builder = request.newBuilder()
if (request.url().host().toString().contains("zhangxinhulian.com")) {
if (request.url.host.toString().contains("zhangxinhulian.com")) {
PhoneUtils.addHeader(builder)
}
chain.proceed(builder.build())
......@@ -54,7 +53,7 @@ object ApiClient {
private val retrofit = retrofit2.Retrofit.Builder()
.client(httpClient)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(GsonInstance.getInstance()))
.baseUrl(NetConfig.BASE_URL)
.build()
......
......@@ -4,7 +4,8 @@ import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.net.api.ICfgInfoApi
import com.zxhl.cms.utils.PhoneUtils
import okhttp3.*
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
......@@ -18,7 +19,7 @@ object EventApiClient {
private val logInterceptor = HttpLoggingInterceptor()
private val paramsInterceptor = Interceptor { chain ->
val request = chain.request()
val builder = request.url().newBuilder()
val builder = request.url.newBuilder()
val params = PhoneUtils.addCommonParam()
val putkeys = params.keys
for (s in putkeys) {
......
......@@ -2,6 +2,7 @@ package com.zxhl.cms.net.callback;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import com.zxhl.cms.AppContext;
import com.zxhl.cms.ad.upload.model.Response;
......@@ -13,6 +14,8 @@ import com.zxhl.cms.utils.RxBus;
import com.zxhl.cms.utils.Utils;
import com.zxhl.cms.net.SettingPreference;
import java.lang.reflect.Type;
import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
......
......@@ -10,7 +10,7 @@ class DownloadInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val originalResponse = chain.proceed(chain.request())
return originalResponse.newBuilder()
.body(DownloadResponseBody(originalResponse.body()!!))
.body(DownloadResponseBody(originalResponse.body!!))
.build()
}
......
package com.zxhl.cms.net.callback
import android.util.Log
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.model.other.FileLoadEvent
import com.zxhl.cms.utils.RxBus
......@@ -23,11 +22,11 @@ class DownloadResponseBody : ResponseBody {
override fun contentType(): MediaType? = responseBody.contentType()
override fun source(): BufferedSource? {
override fun source(): BufferedSource {
if (bufferedSource == null) {
bufferedSource = Okio.buffer(source(responseBody.source()));
bufferedSource = source(responseBody.source()).buffer();
}
return bufferedSource
return bufferedSource as BufferedSource
}
private fun source(source: Source): Source {
......
......@@ -73,7 +73,6 @@ class PayActivity : BaseActivity(), PayContract.View,
)
id_img_back?.setOnClickListener {
finish()
// startActivity(Intent(this,GooglePayActivity::class.java))
}
id_activity_member_close?.setOnClickListener {
finish()
......@@ -231,7 +230,7 @@ class PayActivity : BaseActivity(), PayContract.View,
}
EventUtils.onEvent("member_page_show")
// startActivity(Intent(this,GooglePayActivity::class.java))
}
fun checkChoose() {
......
......@@ -17,7 +17,7 @@ public class GsonInstance {
}
synchronized (GsonInstance.class) {
if (sInstance == null) {
sInstance = new GsonBuilder().disableHtmlEscaping().create();
sInstance = new GsonBuilder().disableHtmlEscaping().serializeNulls().create();
}
}
return sInstance;
......
......@@ -758,12 +758,12 @@ object PhoneUtils {
fun addParam(request: Request, builder: HttpUrl.Builder) {
val params = addCommonParam()
params.put("appLs", Constant.Param.APPLS)
for (i in 0 until request.url().querySize()) {
val url = request.url()
params.put(url.queryParameterName(i), url.queryParameterValue(i))
for (i in 0 until request.url.querySize) {
val url = request.url
params.put(url.queryParameterName(i), url.queryParameterValue(i).toString())
}
for (i in 0 until request.url().querySize()) {
val url = request.url()
for (i in 0 until request.url.querySize) {
val url = request.url
builder.removeAllQueryParameters(url.queryParameterName(i))
}
......
package com.zxhl.cms.utils
import android.text.TextUtils
import com.zxhl.cms.ad.upload.model.Response
import com.zxhl.cms.net.ApiClient.userInfoAPi
import com.zxhl.cms.net.RxSchedulers
......
<resources>
<string name="app_name">LuckyBox</string>
<string name="app_name">MagicBox</string>
<string name="login_faild">登录失败</string>
<string name="login_success">登录成功</string>
<string name="reset_success">修改成功</string>
......
......@@ -4,7 +4,7 @@ if (isDebug.toBoolean()) {
} else {
apply plugin: 'com.android.library'
}
apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
......@@ -40,6 +40,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
repositories {
flatDir {
......
......@@ -4,7 +4,7 @@ if (isDebug.toBoolean()) {
} else {
apply plugin: 'com.android.library'
}
apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
......@@ -40,6 +40,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
repositories {
flatDir {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment