0.1.0 • Published 6 months ago

expo-tappay-ios v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

expo-tappay-ios

TapPay SDK for iOS

Tappay is a great payment service provider which provide many popular payment method.

This module is a wrapper around the iOS Tappay SDK (v2.19.0).

English | 中文版

English

A React Native module for integrating TapPay payment services in iOS applications.

Features

  • Apple Pay integration
  • Easy-to-use API
  • Built for Expo managed and bare workflow

Installation

In managed Expo projects

For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release.

In bare React Native projects

1. Install the package

npm install expo-tappay-ios

2. Configure iOS project

npx pod-install

Configuration

Add the following to your app.json:

{
  "expo": {
    "plugins": [
      [
        "expo-tappay-ios",
        {
          "merchantId": "YOUR_MERCHANT_ID",
          "acceptNetworks": ["Visa", "MasterCard"],
          "appId": YOUR_APP_ID,
          "appKey": "YOUR_APP_KEY",
          "serverType": "sandbox"
        }
      ]
    ]
  }
}

Basic Usage

import expoTappay from 'expo-tappay-ios';

// 1. Setup merchant
await expoTappay.setupMerchant({
  name: "Your Store Name",
  capabilities: "3DS",
  merchantId: "merchant.com.your.id",
  countryCode: "TW",
  currencyCode: "TWD"
});

// 2. Check Apple Pay availability
const isApplePayAvailable = await expoTappay.isApplePayAvailable();

// 3. Start payment
await expoTappay.startPayment({
  cart: [{
    name: "Product Name",
    amount: 100
  }]
});

// 4. Handle payment result
expoTappay.addReceivePrimeListener((event) => {
  if (event.success) {
    console.log("Prime:", event.prime);
    console.log("Total Amount:", event.totalAmount);
    expoTappay.showResult(true);
  } else {
    console.error("Failed to get prime:", event.message);
    expoTappay.showResult(false);
  }
});

中文版

Tappay 是一個優秀的支付服務提供商,提供多種流行的支付方式。

這個模組是基於 iOS Tappay SDK (v2.19.0) 的封裝。

用於在 iOS 應用程式中整合 TapPay 支付服務的 React Native 模組。

功能特點

  • 支援 Apple Pay 整合
  • 簡單易用的 API
  • 支援 Expo managed 和 bare workflow

安裝方式

在 Expo managed 專案中安裝

對於 managed Expo 專案,請參考最新版本的 API 文件中的安裝說明。

在 bare React Native 專案中安裝

安裝步驟

1. 安裝套件

npm install expo-tappay-ios

2. 配置 iOS 專案

npx pod-install

基本設定

在您的 app.json 中加入以下設定:

{
  "expo": {
    "plugins": [
      [
        "expo-tappay-ios",
        {
          "merchantId": "您的商店ID",
          "acceptNetworks": ["Visa", "MasterCard"],
          "appId": 您的應用程式ID,
          "appKey": "您的應用程式金鑰",
          "serverType": "sandbox"
        }
      ]
    ]
  }
}

使用範例

import expoTappay from 'expo-tappay-ios';

// 1. 設定商店資訊
await expoTappay.setupMerchant({
  name: "您的商店名稱",
  capabilities: "3DS",
  merchantId: "merchant.com.your.id",
  countryCode: "TW",
  currencyCode: "TWD"
});

// 2. 檢查 Apple Pay 可用性
const isApplePayAvailable = await expoTappay.isApplePayAvailable();

// 3. 開始付款
await expoTappay.startPayment({
  cart: [{
    name: "商品名稱",
    amount: 100
  }]
});

// 4. 處理付款結果
expoTappay.addReceivePrimeListener((event) => {
  if (event.success) {
    console.log("Prime:", event.prime);
    console.log("總金額:", event.totalAmount);
    expoTappay.showResult(true);
  } else {
    console.error("取得 prime 失敗:", event.message);
    expoTappay.showResult(false);
  }
});

相關資源

API Documentation

Contributing

Contributions are very welcome! Please refer to guidelines described in the contributing guide.