//
//  PayManager.m
//  JZPlus_RN
//
//  Created by 丁乐 on 2020/6/15.
//

#import "PayManager.h"
#import "WXPay.h"
#import "AliPay.h"
#import "ApplePay.h"

@implementation PayManager

- (dispatch_queue_t)methodQueue
{
    return dispatch_get_main_queue();
}

RCT_EXPORT_MODULE()


/**
 微信注册 appKey
 
 @param NSString appId
 */
RCT_EXPORT_METHOD(wechatRegister:(NSString *)appKey link:(NSString *)universalLink)
{
    [WXPay wechatRegister:appKey link:universalLink];
}



/**
 微信支付
 
 @param NSDictionary 支付数据
 @success 成功的回调
 @faild 失败的回调
 */
RCT_EXPORT_METHOD(wechatPay:(NSDictionary *)data success:(RCTPromiseResolveBlock)success faild:(RCTPromiseRejectBlock)faild)
{
    [[WXPay shareInstance] wxpay:data success:success faild:faild];
}


/**
 支付宝支付

 @param NSDictionary 支付数据
 @success 成功的回调
 @faild 失败的回调
 */
RCT_EXPORT_METHOD(aliPay:(NSDictionary *)data success:(RCTPromiseResolveBlock)success faild:(RCTPromiseRejectBlock)faild)
{
    [[AliPay shareInstance] alipay:data success:success faild:faild];
}


/**
 app内购
 
 @param NSDictionary 支付数据
 @success 成功的回调
 @faild 失败的回调
 */
RCT_EXPORT_METHOD(applePay:(NSDictionary *)data success:(RCTPromiseResolveBlock)success faild:(RCTPromiseRejectBlock)faild)
{
    [[ApplePay shareInstance] buy:data success:success faild:faild];
}


@end
