Skip to content

Commit b197acf

Browse files
committed
Bug fixes and performance improvements
1 parent da9d56d commit b197acf

14 files changed

+111
-62
lines changed
Binary file not shown.

FlutterwaveSDK/Classes/App/RaveCardClient.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class FlutterwaveCardClient{
194194
"email": FlutterwaveConfig.sharedConfig().email!,
195195
"currency": FlutterwaveConfig.sharedConfig().currencyCode,
196196
"country":country,
197+
"payment_plan":FlutterwaveConfig.sharedConfig().paymentPlan ?? 0,
197198
// "IP": getIFAddresses().first!,
198199
"tx_ref": FlutterwaveConfig.sharedConfig().transcationRef!,
199200
"device_fingerprint": (UIDevice.current.identifierForVendor?.uuidString)!]

FlutterwaveSDK/Classes/Config/RaveConfig.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class FlutterwaveConfig {
2727
public var country:String = "NG"
2828
public var currencyCode:String = "NGN"
2929
public var narration:String?
30+
public var paymentPlan:Int?
3031
public var isPreAuth:Bool = false
3132
public var isPermanent:Bool = true
3233
public var meta:[[String:String]]?

FlutterwaveSDK/Classes/Model/ChargeCardModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ChargeData:Codable {
2727
let amount, chargedAmount, appFee, merchantFee: Double?
2828
let processorResponse, authModel, currency, ip: String?
2929
let narration, status, authURL, paymentType: String?
30-
let plan: String?
30+
let paymentPlan: Int?
3131
let fraudStatus, chargeType, createdAt: String?
3232
let accountID: Int?
3333
let customer: Customer?
@@ -47,7 +47,7 @@ struct ChargeData:Codable {
4747
case currency, ip, narration, status
4848
case authURL = "auth_url"
4949
case paymentType = "payment_type"
50-
case plan
50+
case paymentPlan = "payment_plan"
5151
case fraudStatus = "fraud_status"
5252
case chargeType = "charge_type"
5353
case createdAt = "created_at"
@@ -112,6 +112,6 @@ protocol FlutterChargeResponse {
112112

113113
extension ChargeData {
114114
func toFlutterResponse() -> FlutterwaveDataResponse{
115-
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: deviceFingerprint, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: authURL, paymentType: paymentType, fraudStatus: fraudStatus, chargeType: chargeType, createdAt: createdAt, plan: plan, id: id, accountID: accountID, customer: customer, card: card)
115+
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: deviceFingerprint, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: authURL, paymentType: paymentType, fraudStatus: fraudStatus, chargeType: chargeType, createdAt: createdAt, paymentPlan: paymentPlan, id: id, accountID: accountID, customer: customer, card: card)
116116
}
117117
}

FlutterwaveSDK/Classes/Model/ChargeSavedCardModel.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ struct DataClass: Codable {
4444
let vbvrespcode: String?
4545
let acctvalrespmsg, acctvalrespcode: JSONNull?
4646
let paymentType: String?
47-
let paymentPlan, paymentPage: JSONNull?
47+
let paymentPlan:Int?
48+
let paymentPage: JSONNull?
4849
let paymentID, fraudStatus, chargeType: String?
4950
let isLive: Int?
5051
let retryAttempt, getpaidBatchID: JSONNull?
@@ -61,8 +62,9 @@ struct DataClass: Codable {
6162
case chargedAmount = "charged_amount"
6263
case appfee, merchantfee, merchantbearsfee, chargeResponseCode, raveRef, chargeResponseMessage, authModelUsed, currency
6364
case ip = "IP"
64-
case narration, status, modalauditid, vbvrespmessage, authurl, vbvrespcode, acctvalrespmsg, acctvalrespcode, paymentType, paymentPlan, paymentPage
65+
case narration, status, modalauditid, vbvrespmessage, authurl, vbvrespcode, acctvalrespmsg, acctvalrespcode, paymentType, paymentPage
6566
case paymentID = "paymentId"
67+
case paymentPlan = "payment_plan"
6668
case fraudStatus = "fraud_status"
6769
case chargeType = "charge_type"
6870
case isLive = "is_live"

FlutterwaveSDK/Classes/Model/FlutterResponseData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public struct FlutterwaveDataResponse {
1313
public let processorResponse, authModel, currency, ip: String?
1414
public let narration, status, authURL, paymentType: String?
1515
public let fraudStatus, chargeType, createdAt: String?
16-
public let plan: String?
16+
public let paymentPlan: Int?
1717
public let id,accountID: Int?
1818
public let customer: Customer?
1919
public let card: CardData?

FlutterwaveSDK/Classes/Model/MpesaVerifyModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct MpesaVerifyData: Codable {
4848

4949
extension MpesaVerifyData{
5050
func toFlutterResponse() -> FlutterwaveDataResponse{
51-
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: nil, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: nil, currency: currency, ip: ip, narration: narration, status: status, authURL:nil, paymentType: nil, fraudStatus: nil, chargeType: nil, createdAt: nil, plan: nil, id: nil, accountID: nil, customer: customer, card: nil)
51+
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: nil, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: nil, currency: currency, ip: ip, narration: narration, status: status, authURL:nil, paymentType: nil, fraudStatus: nil, chargeType: nil, createdAt: nil, paymentPlan: nil, id: nil, accountID: nil, customer: customer, card: nil)
5252
}
5353
}
5454

FlutterwaveSDK/Classes/Model/PwbtVerify.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct PwbtVerifyData: Codable {
5252

5353
extension PwbtVerifyData {
5454
func toFlutterResponse() -> FlutterwaveDataResponse{
55-
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: nil, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: nil, paymentType: paymentType, fraudStatus: nil, chargeType: nil, createdAt: nil, plan: nil, id: nil, accountID: nil, customer: customer, card: nil)
55+
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: nil, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: nil, paymentType: paymentType, fraudStatus: nil, chargeType: nil, createdAt: nil, paymentPlan: nil, id: nil, accountID: nil, customer: customer, card: nil)
5656
}
5757
}
5858

FlutterwaveSDK/Classes/Model/ValidateChargeModel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct ValidChargeData:Codable {
3333
let amount, chargedAmount, appFee, merchantFee: Double?
3434
let processorResponse, authModel, currency, ip: String?
3535
let narration, status, authURL, paymentType: String?
36-
let plan: String?
36+
let paymentPlan: Int?
3737
let fraudStatus, chargeType, createdAt: String?
3838
let accountID: Int?
3939
let customer: Customer?
@@ -53,7 +53,7 @@ struct ValidChargeData:Codable {
5353
case currency, ip, narration, status
5454
case authURL = "auth_url"
5555
case paymentType = "payment_type"
56-
case plan
56+
case paymentPlan = "payment_plan"
5757
case fraudStatus = "fraud_status"
5858
case chargeType = "charge_type"
5959
case createdAt = "created_at"
@@ -65,6 +65,6 @@ struct ValidChargeData:Codable {
6565

6666
extension ValidChargeData {
6767
func toFlutterResponse() -> FlutterwaveDataResponse{
68-
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: deviceFingerprint, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: authURL, paymentType: paymentType, fraudStatus: fraudStatus, chargeType: chargeType, createdAt: createdAt, plan: plan, id: id, accountID: accountID, customer: customer, card: card)
68+
return FlutterwaveDataResponse(txRef: txRef, flwRef: flwRef, deviceFingerprint: deviceFingerprint, amount: amount, chargedAmount: chargedAmount, appFee: appFee, merchantFee: merchantFee, processorResponse: processorResponse, authModel: authModel, currency: currency, ip: ip, narration: narration, status: status, authURL: authURL, paymentType: paymentType, fraudStatus: fraudStatus, chargeType: chargeType, createdAt: createdAt, paymentPlan: paymentPlan, id: id, accountID: accountID, customer: customer, card: card)
6969
}
7070
}

FlutterwaveSDK/Classes/UI/FlutterwavePayViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ public class FlutterwavePayViewController: BaseViewController {
613613
setUpObservers()
614614

615615

616+
616617
self.navigationController?.navigationBar.isHidden = false
617618
self.navigationController?.navigationBar.shadowImage = UIImage()
618619
let navTitle = FlutterwavePayNavTitle(frame: CGRect(x: 0, y: 0, width: 200, height: 40))

FlutterwaveSDK/Classes/UI/MobileMoneyGHView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class MobileMoneyGHView: UIView {
4848
text.rightView = arrowButton
4949
text.rightViewMode = .always
5050
text.translatesAutoresizingMaskIntoConstraints = false
51+
// text.isUserInteractionEnabled = false
5152

5253
return text
5354
}()

FlutterwaveSDK/Classes/UI/NewExtraFlutterwave/FlutterWave+UIPickerView.swift

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,43 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
1919
if let card = flutterwaveCardClient.selectedCard{
2020
//LoadingHUD.shared().show()
2121
CardViewModel.sharedViewModel.sendCardOtp(cardHash: card.cardHash ?? "")
22-
// flutterwaveCardClient.sendOTP(card: card)
22+
// flutterwaveCardClient.sendOTP(card: card)
2323
}
2424
}
2525

26+
27+
2628
@objc func textFieldDidChange(textField: UITextField) {
27-
if (textField == pinViewContainer.hiddenPinTextField){
28-
pinViewContainer.pins.forEach { (item) in
29-
item.backgroundColor = .white
30-
}
31-
32-
for (index,_) in (textField.text?.enumerated())!{
33-
pinViewContainer.pins[index].backgroundColor = .gray
34-
}
35-
if ((textField.text?.count)! == 4){
36-
textField.resignFirstResponder()
37-
}
38-
39-
}
40-
if (textField == debitCardView.cardNumberTextField){
41-
if let count = textField.text?.count {
42-
if count == 6{
29+
if (textField == pinViewContainer.hiddenPinTextField){
30+
pinViewContainer.pins.forEach { (item) in
31+
item.backgroundColor = .white
32+
}
33+
34+
for (index,_) in (textField.text?.enumerated())!{
35+
pinViewContainer.pins[index].backgroundColor = .gray
36+
}
37+
if ((textField.text?.count)! == 4){
38+
textField.resignFirstResponder()
39+
}
40+
41+
}
42+
if (textField == debitCardView.cardNumberTextField){
43+
if let count = textField.text?.count {
44+
if count == 6{
4345
flutterwaveCardClient.amount = self.amount
44-
flutterwaveCardClient.cardfirst6 = textField.text
46+
flutterwaveCardClient.cardfirst6 = textField.text
4547

46-
}
47-
}
48-
}
49-
}
48+
}
49+
}
50+
}
51+
}
52+
53+
//Disable textfield interactions
54+
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
55+
self.resignFirstResponder()
56+
return false
57+
}
58+
5059

5160
public func textFieldDidBeginEditing(_ textField: UITextField) {
5261
textField.layer.borderWidth = 0
@@ -55,8 +64,29 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
5564
bankPicker.selectRow(0, inComponent: 0, animated: true)
5665
self.pickerView(bankPicker, didSelectRow: 0, inComponent: 0)
5766
}
67+
} else if textField == mobileMoneyContentView.mobileMoneyChooseNetwork{
68+
69+
ghsMobileMoneyPicker.selectRow(0, inComponent: 0, animated: true)
70+
self.pickerView(ghsMobileMoneyPicker, didSelectRow: 0, inComponent: 0)
71+
72+
}else if textField == selectUssdBankView.otherBanksTextField{
73+
74+
ussdBankPicker.selectRow(0, inComponent: 0, animated: true)
75+
self.pickerView(ussdBankPicker, didSelectRow: 0, inComponent: 0)
76+
77+
}else if textField == mobileMoneyFRContentContainer.mobileMoneyFRCountry{
78+
francoCountryPicker.selectRow(0, inComponent: 0, animated: true)
79+
self.pickerView(francoCountryPicker, didSelectRow: 0, inComponent: 0)
80+
81+
}else if textField == mobileMoneyZMContentContainer.mobileMoneyChooseNetwork{
82+
zambiaMobileMoneyPicker.selectRow(0, inComponent: 0, animated: true)
83+
self.pickerView(zambiaMobileMoneyPicker, didSelectRow: 0, inComponent: 0)
84+
5885
}
86+
5987
}
88+
89+
6090

6191
public func textFieldDidEndEditing(_ textField: UITextField) {
6292
guard let bankCode = selectedBankCode else {
@@ -223,7 +253,7 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
223253
}
224254
func showWebView(url: String?,ref:String?){
225255
//Collapse opened Tabs
226-
// self.handelCloseOrExpandSection(section: 0)
256+
// self.handelCloseOrExpandSection(section: 0)
227257
//Show web view
228258
//let storyBoard = UIStoryboard(name: "Rave", bundle: nil)
229259
let controller = RavePayWebViewController()
@@ -276,19 +306,19 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
276306
}
277307
case .bank:
278308
print("")
279-
// accountOtpContentContainer.alpha = 0
280-
// accountOtpContentContainer.otpMessage.text = message
281-
// accountOtpContentContainer.otpTextField.text = ""
282-
// accountOtpContentContainer.otpButton.addTarget(self, action: #selector(accountOTPButtonTapped), for: .touchUpInside)
283-
// raveAccountClient.transactionReference = flwRef
284-
// UIView.animate(withDuration: 0.6, animations: {
285-
// self.accountOtpContentContainer.alpha = 1
286-
// self.accountFormContainer.alpha = 0
287-
// self.selectBankAccountView.alpha = 0
288-
// }) { (success) in
289-
// self.accountFormContainer.isHidden = true
290-
// self.selectBankAccountView.isHidden = true
291-
// }
309+
// accountOtpContentContainer.alpha = 0
310+
// accountOtpContentContainer.otpMessage.text = message
311+
// accountOtpContentContainer.otpTextField.text = ""
312+
// accountOtpContentContainer.otpButton.addTarget(self, action: #selector(accountOTPButtonTapped), for: .touchUpInside)
313+
// raveAccountClient.transactionReference = flwRef
314+
// UIView.animate(withDuration: 0.6, animations: {
315+
// self.accountOtpContentContainer.alpha = 1
316+
// self.accountFormContainer.alpha = 0
317+
// self.selectBankAccountView.alpha = 0
318+
// }) { (success) in
319+
// self.accountFormContainer.isHidden = true
320+
// self.selectBankAccountView.isHidden = true
321+
// }
292322
}
293323
}
294324
@objc func accountOTPButtonTapped(){
@@ -320,7 +350,7 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
320350
guard let otp = otpContentContainer.otpTextField.text, otp != "" else {
321351
return
322352
}
323-
// LoadingHUD.shared().show()
353+
// LoadingHUD.shared().show()
324354
flutterwaveCardClient.otp = otp
325355
flutterwaveCardClient.isSaveCardCharge = "1"
326356
flutterwaveCardClient.saveCardPayment = "saved-card"
@@ -331,15 +361,15 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
331361
self.pinAction()
332362
}
333363

334-
364+
335365
func pinAction(){
336-
self.view.endEditing(true)
337-
guard let pin = self.pinViewContainer.hiddenPinTextField.text else {return}
338-
flutterwaveCardClient.bodyParam?.merge(["authorization":
339-
["mode":"pin","pin":pin]
340-
])
341-
flutterwaveCardClient.chargeCard()
342-
}
366+
self.view.endEditing(true)
367+
guard let pin = self.pinViewContainer.hiddenPinTextField.text else {return}
368+
flutterwaveCardClient.bodyParam?.merge(["authorization":
369+
["mode":"pin","pin":pin]
370+
])
371+
flutterwaveCardClient.chargeCard()
372+
}
343373

344374
@objc func billAddressButtonTapped(){
345375

@@ -359,21 +389,23 @@ extension FlutterwavePayViewController : UITextFieldDelegate,CardSelect,UIPicker
359389
func billAddressAction(){
360390
self.view.endEditing(true)
361391
guard let zip = self.billingAddressContainer.zipCodeTextField.text, let city = self.billingAddressContainer.cityTextField.text,
362-
let address = self.billingAddressContainer.billingAddressTextField.text, let country = self.billingAddressContainer.countryTextField.text , let state = self.billingAddressContainer.stateTextField.text else {return}
392+
let address = self.billingAddressContainer.billingAddressTextField.text, let country = self.billingAddressContainer.countryTextField.text , let state = self.billingAddressContainer.stateTextField.text else {return}
363393

364394
flutterwaveCardClient.bodyParam?.merge(["authorization":
365-
["mode":"avs_noauth","city": city,"address":address, "state":state, "country":country, "zipcode": zip]
395+
["mode":"avs_noauth","city": city,"address":address, "state":state, "country":country, "zipcode": zip]
366396
])
367397

368398
flutterwaveCardClient.chargeCard()
369399
}
370400

401+
402+
//TODO
371403
public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
372404
let ussdBanks = getUssdBanks()
373405
let francophoneCountries = getFrancophoneCountries(countryCode: FlutterwaveConfig.sharedConfig().currencyCode)
374-
// print("Current PickerView Tag \(pickerView.tag)")
406+
// print("Current PickerView Tag \(pickerView.tag)")
375407
if pickerView.tag == 12 {
376-
// print("Country Code logic")
408+
// print("Country Code logic")
377409
if let count = self.banks?.count{
378410
return count
379411
}else{

FlutterwaveSDK/Classes/UI/NewExtraFlutterwave/Flutterwave+Observers.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ extension FlutterwavePayViewController {
1616
setUpErrorObservers()
1717
setUpSuccessObservers()
1818
fetchBanks()
19+
modalSwipeDisabled()
20+
}
21+
22+
func modalSwipeDisabled(){
23+
if #available(iOS 13.0, *) {
24+
self.isModalInPresentation = true
25+
}
1926
}
2027

2128
func setUpNextActionObservers(){

0 commit comments

Comments
 (0)