Skip to content
react-native pay for Ali && WeiXin
Objective-C Java JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android 1. 更新支付宝 sdk May 31, 2018
ios release in 1.0.0 Oct 25, 2018
.gitignore init Mar 24, 2018
.travis.yml add the travis.yml Apr 12, 2019
LICENSE Create LICENSE Aug 2, 2018
README.md modify the readme.md Apr 12, 2019
index.js modify Apr 24, 2018
package.json release in 1.0.0 Oct 25, 2018

README.md

Travis (.org) npm npm GitHub issues

PRs Welcome npm

react-native-wx-ali-pay

react-native版 微信支付,支付宝 插件

Install

npm install react-native-wx-ali-pay -S

react-native link react-native-wx-ali-pay

Useage

import Pay from 'react-native-wx-ali-pay'

const wxObj = {
  appid: 'appid',
  partnerid: 'partnerid',
  noncestr: 'noncestr',
  timestamp: 'timestamp',
  prepayid: 'prepayid',
  package: 'package',
  sign: 'sign',
}

const aliObj = {
  orderString: 'orderString'
}

Pay.onWxPay(wxObj).then(e => console.info(e)).catch(err => alert(err))

Pay.onAliPay(aliObj).then(e => console.info(e)).catch(err => alert(err))

StepUp in Java && OC

Android

Step1

android/app/src/main/java/com/xx/ 下创建wxapi文件夹

Step2

新建文件 WXPayEntryActivity.java

package com.xxx.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.timson.react_native_wx_ali_pay.wxpay.WXPay;

public class WXPayEntryActivity extends Activity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WXPay.handlerIntent(getIntent());
        finish();
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        WXPay.handlerIntent(intent);
    }
}

Step3

AndroidManifest.xml 加上

<activity
	android:name=".MainActivity"
....
</activity>
<activity
	android:name=".wxapi.WXPayEntryActivity"
	android:exported="true"
	android:launchMode="singleTop" />

iOS

Step1

在工程target的General -> Link Frameworks and Libraries -> 加入libsqlite3.tbd, libc++.tbd, libz.tbd

Step2

在工程target的General -> Link Frameworks and Libraries -> 加入AlipaySDK.framework,CoreMotion.framework(注意: 加入的AlipaySDK.framework需要是插件支付宝文件里的AlipaySDK.framework)

Step3

在工程target的Build Settings-> Frameworks Search Paths -> 加入"$(SRCROOT)/../node_modules/react-native-wx-ali-pay/ios/PaySdk/支付宝"

Step4

在工程target的Build Settings-> Header Search Paths -> 加入"$(SRCROOT)/../node_modules/react-native-wx-ali-pay/ios/PaySdk",并将状态修改为recursive

Step5

在工程target的Info-> URL Types -> 点左下角'+'新增一项并将URL Schemes"修改为WXPay

AppDegelate.m

添加文件添加内容 --- 下面的减函数

#import <WXApi.h>
#import <WXApiManager.h>
#import <AlipaySDK/AlipaySDK.h>

// 支持所有iOS系统
// 支持所有iOS系统
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  if ([url.host isEqualToString:@"safepay"]) {
    //支付宝回调 ...
    //添加回调方法
    [[AlipaySDK defaultService]processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
      [[NSNotificationCenter defaultCenter]postNotificationName:@"aliPayReslut" object:nil userInfo:resultDic];
    }];
      return YES;
  } else {
    //微信回调
    return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
  }
}

Contributer

OYWeijian

lekenny

You can’t perform that action at this time.