-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElePayObjCBridge.swift
More file actions
45 lines (41 loc) · 1.44 KB
/
ElePayObjCBridge.swift
File metadata and controls
45 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// ElePayObjCBridge.swift
// ElePayObjCBridge
//
// Created by xuzhe on 2019/01/15.
// Copyright © 2018 elestyle.jp. All rights reserved.
//
import ElepaySDK
@objc
final public class ElePayObjCBridge: NSObject {
@objc
public static func initElePay(publicKey: String) {
Elepay.initApp(key: publicKey)
}
@objc
public static func handleOpenURL(_ url: URL) -> Bool {
return Elepay.handleOpenURL(url)
}
@objc
@discardableResult
public static func handlePaymentEvent(payload: String, senderViewController sender: UIViewController) -> Bool {
return Elepay.handlePayment(chargeJSON: payload, viewController: sender) { (paymentResult) in
switch (paymentResult) {
case let .succeeded(paymentId):
print("Payment ID: \(paymentId), Payment Succeed")
case let .cancelled(paymentId):
print("Payment ID: \(paymentId), Canceled by user")
case let .failed(paymentId, error):
switch (error) {
case let .alreadyMakingPayment(paymentId):
print("Already making payment: \(paymentId)")
default:
print("Payment ID: \(paymentId ?? ""), Make Payment Failed \(String(describing: error.errorDescription))")
}
@unknown default:
// handle newly added case here
fatalError()
}
}
}
}