npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sesame/react-native-alipay

v0.1.2

Published

alipay sdk wrapper for react native 0.60+

Downloads

10

Readme

@sesame/react-native-alipay

Alipay SDK wrapper for react native 0.60+, support iOS and android

Table of Contents

Installation

install package

$ yarn add @sesame/react-native-alipay --save
$ cd ios && pod install && cd ..

configure iOS project

reference: alipay sdk ios integrate guide

  • ios/YOUR-APP-NAME/AppDelegate.m

    add following code(to be verified):

    #import <React/RCTLinkingManager.h>
      
    @implementation AppDelegate
      
    // ...
      
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
      sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
      return [RCTLinkingManager application:application openURL:url
                          sourceApplication:sourceApplication annotation:annotation];
    }
      
    // NOTE: 9.0以后使用新API接口
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
                options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
    {
      return [RCTLinkingManager application:application openURL:url options:options];
    }
      
    @end
    
  • TARGETS->Info->URL Types

    1. create URL Type By Click '+'

    2. Identifier, input "alipay"

    3. URL Schemes, input any string can distinguish your app from other app, for example, use your app's bundle id

configure android project

reference: alipay sdk android integrate guide

  • copy alipaySdk.aar file

    from: node_modules/@sesame/react-native-alipay/android/lib/alipaySdk-15.6.5-20190718211148.aar

    to: YOUR-PROJECT/android/app/lib/alipaySdk-15.6.5-20190718211148.aar

  • YOUR-PROJECT/android/build.gradle

    add flatDir

      allprojects {
          repositories {
              // ...
                
              flatDir {
                  dirs "lib"
              }
          }
      }

API Documentation

Alipay.pay(orderStr)

Returns object with following fields:

|field|type|description| |:----|:---|:----------| |resultStatus|String|See Response code description| |result|String|Result data in json string format| |memo|String|Reserved field, nothing|

The result data has following fields:

|field|type|description| |:----|:---|:----------| |code|String|结果码,具体见公共错误码| |msg|String|处理结果的描述,信息来自于code返回结果的描述| |app_id|String|支付宝分配给开发者的应用Id| |out_trade_no|String|商户网站唯一订单号| |trade_no|String|该交易在支付宝系统中的交易流水号| |total_amount|String|该笔订单的资金总额,单位为RMB-Yuan| |seller_id|String|收款支付宝账号对应的支付宝唯一用户号| |charset|String|编码格式| |timestamp|String|时间|

Example code:

import Alipay from '@sesame/react-native-alipay';

// APP支付
try {
  // get from server, signed
  let orderStr = 'app_id=xxxx&method=alipay.trade.app.pay&charset=utf-8&timestamp=2014-07-24 03:07:50&version=1.0&notify_url=https%3A%2F%2Fapi.xxx.com%2Fnotify&biz_content=%7B%22subject%22%3A%22%E5%A4%A7%E4%B9%90%E9%80%8F%22%2C%22out_trade_no%22%3A%22xxxx%22%2C%22total_amount%22%3A%229.00%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&sign_type=RSA2&sign=xxxx';
  let response = await Alipay.pay(orderStr);
  console.info(response);

  let { resultStatus, result, memo } = response;
  let { code, msg, app_id, out_trade_no, trade_no, total_amount, seller_id, charset, timestamp } = JSON.parse(result);

  // TODO: ...

} catch (error) {
  console.error(error);
}

Response code description

|code|description| |:-----------|:----------| |9000|操作成功| |8000|正在处理中| |4000|操作失败| |5000|重复请求| |6001|用户中途取消| |6002|网络连接出错|

Todo

  • [ ] test each api
  • [ ] add api usage in example project

License

MIT