React-Native調用支付寶,微信


  • https://www.pingxx.com/docs/downloads
  • Ping++ 是為移動端應用以及 PC 網頁量身打造的下一代支付系統,通過一個 SDK 便可以同時支持移動端以及 PC 端網頁的多種主流支付渠道,你只需要一次接入即可完成多個渠道的接入。 Ping++ SDK 包括 Client SDK 和 Server SDK 兩部分,支持主流的七種后端開發語言,適配了 Android,iOS 和 HTML5 三種移動端平台以及 PC 端網頁。
    支持以下渠道支付
    支付寶 (alipay)
    微信支付 (wx)
    銀聯支付(upacp)
    百付寶Wap (bfb_wap)
    QQ錢包 (qpay)

  • /**
     * Sample React Native App
     * https://github.com/facebook/react-native
     * @flow
     */
    
    import React, { Component } from 'react';
    import {
      AppRegistry,
      StyleSheet,
      Text,
      View,
      TouchableOpacity
    } from 'react-native';
    
    var NetUtil = require('./netutil.js');
    var Pingpp = require('pingpp-react-native');
    
    export default class PingppDemoApp extends Component {
      setDebugModel(enabled) {
        Pingpp.setDebugModel(enabled);
      };
    
      pay(channel) {
        NetUtil.postJson(
          "http://218.244.151.190/demo/charge",
          {amount: 1, channel: channel, order_no: new Date().getTime()},
          function(object) {
            Pingpp.createPayment(
              {
                "object":object,
                "scheme":"pingppdemoapp"
              }, function(res, error) {
                alert(res);
                console.log(error);
                alert(JSON.stringify(error));
              }
            );
          }
        );
      }
    
      render() {
        return (
          <View style={styles.container}>
            <TouchableOpacity onPress = {()=>{this.pay("alipay")}}>
              <Text style={styles.welcome}>支付寶</Text>
            </TouchableOpacity>
            <TouchableOpacity onPress={()=>{this.pay("wx")}}>
              <Text style={styles.welcome}>微信</Text>
            </TouchableOpacity>
            <TouchableOpacity onPress={()=>{this.pay("upacp")}}>
              <Text style={styles.welcome}>銀聯</Text>
            </TouchableOpacity>
            <TouchableOpacity onPress={()=>{this.pay("qpay")}}>
              <Text style={styles.welcome}>QQ錢包</Text>
            </TouchableOpacity>
            <TouchableOpacity onPress={()=>{this.setDebugModel(true)}}>
              <Text style={styles.welcome}>開啟調試</Text>
            </TouchableOpacity>
          </View>
        );
      }
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
      },
      welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
      },
      instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
      },
    });
    
     
     

     


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM