1.1
tj
2025-04-09 2b446a5fd5d8f9b8c0f1e3acef1eef7ad9adb6f9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.example.firstapp.pay
 
import android.app.Activity
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
 
object PayAbility {
 
 
    private val wxPayResultLiveData = MutableLiveData<Int?>()
    /**
     * 支付宝支付方法
     */
    fun aliPay(activity: Activity, orderInfo: String, observer: Observer<PayResult>) {
        AliPayHelper.pay(activity, orderInfo, observer)
    }
 
    /**
     * 微信支付方法
     */
    fun wxPay(activity: Activity, orderInfo: Map<String,String>, observer: Observer<Int?>) {
        if(activity is FragmentActivity){
            wxPayResultLiveData.observe(activity, observer)
        }
        WxPayHelper.pay(activity, orderInfo, observer)
    }
 
    internal fun postWXPayResult(result: Int) {
        wxPayResultLiveData.postValue(result)
        wxPayResultLiveData.value= null
    }
 
 
}