// // AliPay.m // UnityAliPay // // Created by Fenix Wang on 2017/8/14. // Copyright © 2017年 Fenix Wang. All rights reserved. // #import "AliPay.h" #import @implementation AliPay - (void)payResult:(NSString *)gameObj resultDic:(NSDictionary *)resultDic { NSLog(@"reslut = %@", resultDic); NSString *method = @"OnPayResult"; NSString *resultStatus = [resultDic objectForKey:@"resultStatus"]; NSString *result = [resultDic objectForKey:@"result"]; NSString *value = [NSString stringWithFormat:@"%@|%@", resultStatus, result]; UnitySendMessage([gameObj UTF8String], [method UTF8String], [value UTF8String]); } @end extern "C" { void UnitySendMessage(const char* obj, const char* method, const char* msg); void aliPay(const char* orderInfo, const char* gameObjectName) { NSString *orderInfoStr = [NSString stringWithUTF8String:orderInfo]; NSString *gameObjectNameStr = [NSString stringWithUTF8String:gameObjectName]; [[AlipaySDK defaultService] payOrder:orderInfoStr fromScheme:@"MyLovelyGarden" callback:^(NSDictionary *resultDic) { [[[AliPay alloc] init] payResult:gameObjectNameStr resultDic:resultDic]; }]; } }