AtoneCon 0.0.4

AtoneCon 0.0.4

测试测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2020年6月
SPM支持 SPM

Yuta AizawaDung Duong C. 维护。



 
依赖
ObjectMapper~> 4.2
SAMKeychain~> 1.5
 

AtoneCon 0.0.4

  • 作者
  • 亚洲科技有限公司

在此处查看英文文档

atone支付模块导入库(iOS)

A. 要件

  • iOS 8.0+
  • Xcode 8.3

B. 安装

使用CocoaPods

嵌入式框架需要至少iOS 8的部署目标

CocoaPods

CocoaPod的安装

有两种方法。

方法 1: 作为全局Ruby Gem安装

CocoaPods是Cocoa项目的依赖关系管理器,可以使用以下命令进行安装

gem install cocoapods
方法 2: 通过绑包方式按项目安装
  • 步骤 1: 打开 终端 窗口,执行以下命令:
gem install bundler
  • 步骤 2: 在项目根目录下的Gemfile中指定依赖项
source 'https://rubygems.org.cn'
gem 'cocoapods', '~> 1.2.0'
  • 步骤 3: 从指定的源安装所需的全部gem
bundle install

Podfile的配置

构建AtoneCon 1.0+需要CocoaPods 1.2+

使用CocoaPods将AtoneCon框架集成到Xcode项目中,需要在Podfile中指定

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks! # swift project

pod 'AtoneCon', '~> 1.0'

根据需要,可以使用Pod、特定版本、或自己分支的最新版本。这种情况下,可以在pod声明中指定。

注意:需要更改AtoneCon库存储库的链接中的以下命令。

  • 使用存储库的master分支
pod 'AtoneCon', :git => '[email protected]:netprotections/atonecon-ios.git'
  • 使用除master之外的其他分支
pod 'AtoneCon', :git => '[email protected]:netprotections/atonecon-ios.git', :branch => '...'
  • 使用存储库的标签
pod 'AtoneCon', :git => '[email protected]:netprotections/atonecon-ios.git', :tag => '...'
  • 或者指定提交
pod 'AtoneCon', :git => '[email protected]:netprotections/atonecon-ios.git', :commit => '...'

安装AtoneCon

以下命令执行:

[bundle exec] pod install

使用方法C.

1. 配置

// 支払いを実行する前に設定オプションを用意する必要がある
var options = AtoneCon.Options(publicKey: "xxxyyyzzz")
options.environment = .development
let atoneCon = AtoneCon.shared
atoneCon.config(options)
atoneCon.delegate = self // AtoneConDelegate

2. 实行的支付

创建新支付

// 要素必須

var payment = AtoneCon.Payment(
    amount: 10,
    shopTransactionNo: "",
    checksum: "zzzccccvvvvv" // チェックサムは、店舗の秘密鍵と支払い情報から初期化される


/**
下記は要素必須ではない項目。 ただし、値がある場合はその値をパラメータに必ず設定しなければならない。
*/

payment.salesSettled = false // Bool?
payment.descriptionTrans = "備考です。" // String?

购买者的配置

用户内容-新购买者创建
// 要素必須
var customer = AtoneCon.Customer(name: "接続テスト")

/** 
下記は要素必須ではない項目。 ただし、値がある場合はその値をパラメータに必ず設定しなければならない。
*/

customer.nameKana = "セツゾクテスト" // String?
customer.companyName = "(株)ネットプロテクションズ" // String?
...
...
Users' configuration
payment.customer = customer

服务提供方(配送方)的配置(attribute不是必需的)

服务提供地点(配送地点) 的新增
// 要素必須
var desCustomer = AtoneCon.DesCustomer(
    name: "銀座太郎", 
    zipCode: "123-1234", 
    address: "東京都中央区銀座1-10ー6 銀座ファーストビル4階"
)

/**
下記は要素必須ではない項目。 ただし、値がある場合はその値をパラメータに必ず設定しなければならない。
*/

desCustomer.nameKana = "ぎんざたろう" // String?
desCustomer.companyName = "株式会社ネットプロテクションズ" // String?
...
服务提供方(配送方) 的配置
payment.desCustomers = [desCustomer]

商品明细的配置

创建新商品明细
// 要素必須
var item = AtoneCon.Item(
    id: "1", 
    name: "10円チョコ", 
    price: 10, 
    count: 1
)

/**
下記は要素必須ではない項目。 ただし、値がある場合はその値をパラメータに必ず設定しなければならない。
*/

item.url = "https://atone.be/items/1"
商品详情配置
payment.items = [item]

执行的支付

AtoneCon.shared.performPayment(payment)

3. 支付的委托处理

extension YourPaymentController: AtoneConDelegate {
    func atoneCon(atoneCon: AtoneCon, didReceivePaymentEvent event: AtoneCon.PaymentEvent) {
        switch event {
        case .authenticated(let authenToken):
            // authenTokenを保存して後で使用する etc...
        case .cancelled:
            // 決済のキャンセル
        case .failed(let response):
            // 決済プロセスの失敗
            /* 決済のプロパティが正しく初期化されていない場合、responeは次のような形式のオブジェクトになる
                {
                    "name":ExampleException,
                    "message":"error message"
                    "errors" :[
                        "code": EATN.......,
                        "messages": ["error message 1", "error message 2"]
                        "params": ["param1", "param2"]
                    ]
                }

            決済が失敗した場合、responeは次のような形式のオブジェクトになる
                {
                    "id": "tr_aaaaaaa",
                    "authorization_result": 2, // 2: NG
                    "authorization_result_ng_reason":9 // 1: Exceeded the allowed amount or 9: other
                    "subtract_point":0
                }
            
            */
        case .finished(let response):
            // payment finished
            /*
            決済が完了すると、responeは次のような形式のオブジェクトになる
            {
                "id":"tr_aaaaaaa",
                "authorization_result":1, // 1: OK
                "subtract_point":3
            }
            */
        }
    }
}

错误 D


详细内容请参考附页“atone导入手册”