Skip to content

Commit

Permalink
P-2021-12-29:User_Interface->Payment_And_Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
Marzouq Almukhlif authored and Marzouq Almukhlif committed Dec 29, 2021
1 parent 1c184bd commit f36eb50
Show file tree
Hide file tree
Showing 12 changed files with 1,085 additions and 1,175 deletions.
Binary file modified mudaris/.DS_Store
Binary file not shown.
12 changes: 8 additions & 4 deletions mudaris/Mudaris.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
B8126C3C2758D9C6009C9338 /* DIN NEXT™ ARABIC BOLD.otf in Resources */ = {isa = PBXBuildFile; fileRef = B8126C362758D92A009C9338 /* DIN NEXT™ ARABIC BOLD.otf */; };
B8126C3D2758D9C6009C9338 /* DIN NEXT™ ARABIC MEDIUM .otf in Resources */ = {isa = PBXBuildFile; fileRef = B8126C342758D92A009C9338 /* DIN NEXT™ ARABIC MEDIUM .otf */; };
B83D3492276614D2007D3D6E /* InvoiceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B83D3491276614D2007D3D6E /* InvoiceController.swift */; };
B856CB02277B4EB40004CC55 /* TimeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B856CB01277B4EB40004CC55 /* TimeCell.swift */; };
B8C3121027536DB70036BC1E /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8C3120F27536DB70036BC1E /* DetailsViewController.swift */; };
B8DB64FD274AF2F600D86D95 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB64FC274AF2F600D86D95 /* AppDelegate.swift */; };
B8DB64FF274AF2F600D86D95 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB64FE274AF2F600D86D95 /* SceneDelegate.swift */; };
Expand All @@ -29,7 +30,7 @@
B8DB6515274B028400D86D95 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB6514274B028400D86D95 /* LoginViewController.swift */; };
B8DB6518274B02AC00D86D95 /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB6517274B02AC00D86D95 /* SignUpViewController.swift */; };
B8F551D6277482DB0083CF60 /* payMethodsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F551D5277482DB0083CF60 /* payMethodsCell.swift */; };
B8F551D8277488C50083CF60 /* ViewController+MFSDKServicesCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F551D7277488C50083CF60 /* ViewController+MFSDKServicesCall.swift */; };
B8F551D8277488C50083CF60 /* InvoiceController+MFSDKServicesCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F551D7277488C50083CF60 /* InvoiceController+MFSDKServicesCall.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -46,6 +47,7 @@
B8126C362758D92A009C9338 /* DIN NEXT™ ARABIC BOLD.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DIN NEXT™ ARABIC BOLD.otf"; sourceTree = "<group>"; };
B8126C372758D92A009C9338 /* DIN NEXT™ ARABIC REGULAR.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DIN NEXT™ ARABIC REGULAR.otf"; sourceTree = "<group>"; };
B83D3491276614D2007D3D6E /* InvoiceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvoiceController.swift; sourceTree = "<group>"; };
B856CB01277B4EB40004CC55 /* TimeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeCell.swift; sourceTree = "<group>"; };
B8C3120F27536DB70036BC1E /* DetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = "<group>"; };
B8DB64F9274AF2F600D86D95 /* Mudaris.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Mudaris.app; sourceTree = BUILT_PRODUCTS_DIR; };
B8DB64FC274AF2F600D86D95 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -59,7 +61,7 @@
B8DB6514274B028400D86D95 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
B8DB6517274B02AC00D86D95 /* SignUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpViewController.swift; sourceTree = "<group>"; };
B8F551D5277482DB0083CF60 /* payMethodsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = payMethodsCell.swift; path = Mudaris/payMethodsCell.swift; sourceTree = SOURCE_ROOT; };
B8F551D7277488C50083CF60 /* ViewController+MFSDKServicesCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+MFSDKServicesCall.swift"; sourceTree = "<group>"; };
B8F551D7277488C50083CF60 /* InvoiceController+MFSDKServicesCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "InvoiceController+MFSDKServicesCall.swift"; sourceTree = "<group>"; };
C2D04905DD485E37ABD05507 /* Pods-Mudaris.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mudaris.debug.xcconfig"; path = "Target Support Files/Pods-Mudaris/Pods-Mudaris.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -102,7 +104,7 @@
B8126C2F2758B05F009C9338 /* TeacherViewController.swift */,
B8C3120F27536DB70036BC1E /* DetailsViewController.swift */,
B83D3491276614D2007D3D6E /* InvoiceController.swift */,
B8F551D7277488C50083CF60 /* ViewController+MFSDKServicesCall.swift */,
B8F551D7277488C50083CF60 /* InvoiceController+MFSDKServicesCall.swift */,
);
path = Controllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -177,6 +179,7 @@
B8DB64FB274AF2F600D86D95 /* Mudaris */ = {
isa = PBXGroup;
children = (
B856CB01277B4EB40004CC55 /* TimeCell.swift */,
B8F551D5277482DB0083CF60 /* payMethodsCell.swift */,
B8126C312758D8F0009C9338 /* Fonts */,
B80A52A4274B6C6200FEA10A /* Delegates */,
Expand Down Expand Up @@ -317,10 +320,11 @@
B8DB64FF274AF2F600D86D95 /* SceneDelegate.swift in Sources */,
B83D3492276614D2007D3D6E /* InvoiceController.swift in Sources */,
B80A52B6274BD0BD00FEA10A /* Teachers.swift in Sources */,
B856CB02277B4EB40004CC55 /* TimeCell.swift in Sources */,
B8DB6515274B028400D86D95 /* LoginViewController.swift in Sources */,
B8DB6512274B027B00D86D95 /* MainViewController.swift in Sources */,
B80A52AE274B73BB00FEA10A /* TeacherTableViewCell.swift in Sources */,
B8F551D8277488C50083CF60 /* ViewController+MFSDKServicesCall.swift in Sources */,
B8F551D8277488C50083CF60 /* InvoiceController+MFSDKServicesCall.swift in Sources */,
B8C3121027536DB70036BC1E /* DetailsViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
34 changes: 22 additions & 12 deletions mudaris/Mudaris/Controllers/DetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class DetailsViewController: UIViewController {
// Do any additional setup after loading the view.

checkBoxButton.setBackgroundImage(UIImage(named: "checkBox_Yes"), for: .selected)
self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController!.navigationBar.shadowImage = UIImage()
self.navigationController!.navigationBar.isTranslucent = true
}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -55,28 +58,35 @@ class DetailsViewController: UIViewController {
@IBAction func requestButtonTapped(_ sender: UIButton) {
if checkBoxButton.isSelected {
print("~~ YES")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let pvc = storyboard.instantiateViewController(withIdentifier: "InvoiceController") as! InvoiceController
pvc.array = array
pvc.arrayDate = array?.requestDate
pvc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(pvc, animated: true, completion: nil)
performSegue(withIdentifier: "requestShow", sender: nil)
} else {
print("~~ NO")
}

}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
switch segue.identifier {
case "reservationShow":
if let vc = segue.destination as? InvoiceController {
vc.array = array
vc.arrayDate = array?.reservationDate
}
case "requestShow":
if let vc = segue.destination as? InvoiceController {
vc.array = array
vc.arrayDate = array?.reservationDate
}
default:
print("Other")
}
}


@IBAction func reservationButtonTapped(_ sender: UIButton) {
if checkBoxButton.isSelected {
print("~~ YES")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let pvc = storyboard.instantiateViewController(withIdentifier: "InvoiceController") as! InvoiceController
pvc.array = array
pvc.arrayDate = array?.reservationDate
pvc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
self.present(pvc, animated: true, completion: nil)
performSegue(withIdentifier: "reservationShow", sender: nil)
} else {
print("~~ NO")
}
Expand Down
147 changes: 147 additions & 0 deletions mudaris/Mudaris/Controllers/InvoiceController+MFSDKServicesCall.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
//
// ViewController+MFSDKServicesCall.swift
// MFSDKDemo-Swift
//
// Created by Elsayed Hussein on 8/29/19.
// Copyright © 2019 Elsayed Hussein. All rights reserved.
//

import MFSDK

extension InvoiceController {
func initiatePayment() {
payButton.isEnabled = false
let request = generateInitiatePaymentModel()
// startLoading()
MFPaymentRequest.shared.initiatePayment(request: request, apiLanguage: .arabic, completion: { [weak self] (result) in
// self?.stopLoading()
switch result {
case .success(let initiatePaymentResponse):
self?.paymentMethods = initiatePaymentResponse.paymentMethods
self?.collectionView.reloadData()
case .failure(let failError):
// self?.showFailError(failError)
print("")
}
})
}


func executeApplePayPayment(paymentMethodId: Int) {
let request = getExecutePaymentRequest(paymentMethodId: paymentMethodId)
if #available(iOS 13.0, *) {
MFPaymentRequest.shared.executeApplePayPayment(request: request, apiLanguage: .arabic) { (response, invoiceId) in
switch response {
case .success(let executePaymentResponse):
if let invoiceStatus = executePaymentResponse.invoiceStatus {
print("showSuccess1 \(invoiceStatus)")
self.dismiss(animated: true, completion: nil)
}
case .failure(let failError):
self.dismiss(animated: true, completion: nil)
print("showFailError1 \(failError.errorDescription)")
}
}
} else {
MFPaymentRequest.shared.executeApplePayPayment(request: request, apiLanguage: .arabic) { response, invoiceId in
switch response {
case .success(let executePaymentResponse):
if let invoiceStatus = executePaymentResponse.invoiceStatus {
self.dismiss(animated: true, completion: nil)
print("showSuccess2 \(invoiceStatus)")
}
case .failure(let failError):
self.dismiss(animated: true, completion: nil)
print("showFailError2 \(failError.errorDescription)")
}
}
}
}

func executePayment(paymentMethodId: Int) {
let request = getExecutePaymentRequest(paymentMethodId: paymentMethodId)
MFPaymentRequest.shared.executePayment(request: request, apiLanguage: .arabic) { response, invoiceId in
switch response {
case .success(let executePaymentResponse):
if let invoiceStatus = executePaymentResponse.invoiceStatus {
print("showSuccess3 \(invoiceStatus)")
self.performSegue(withIdentifier: "showMain", sender: nil)

// DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(30)) {
// self.dismiss(animated: true, completion: nil)
// }

}
case .failure(let failError):
print("showFailError3 \(failError.errorDescription)")
self.dismiss(animated: true, completion: nil)

}
}
}


func sendPayment() {
let request = getSendPaymentRequest()
MFPaymentRequest.shared.sendPayment(request: request, apiLanguage: .arabic) { [weak self] (result) in
switch result {
case .success(let sendPaymentResponse):
if let invoiceURL = sendPaymentResponse.invoiceURL {
// self?.errorCodeLabel.text = "Success"
// self?.resultTextView.text = "result: send this link to your customers \(invoiceURL)"
}
case .failure(let failError):
// self?.showFailError(failError)
print("showFailError \(failError.errorDescription)")
}

}
}


private func generateInitiatePaymentModel() -> MFInitiatePaymentRequest {
let request = MFInitiatePaymentRequest()
return request
}



//// PAY
private func getExecutePaymentRequest(paymentMethodId: Int) -> MFExecutePaymentRequest {
let request = MFExecutePaymentRequest(invoiceValue: invoiceValue , paymentMethod: paymentMethodId)
request.customerEmail = "[email protected]"// must be email
request.customerMobile = "112233"
request.customerName = "Test MyFatoorah"
let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss")
request.customerAddress = address
request.language = .arabic
request.mobileCountryCode = MFMobileCountryCodeISO.saudiArabia.rawValue
request.displayCurrencyIso = .saudiArabia_SAR
return request
}



func getSendPaymentRequest() -> MFSendPaymentRequest {
// let invoiceValue = Decimal(string: amountTextField.text ?? "") ?? 0
let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .all, customerName: "Test")

//request.userDefinedField = ""
request.customerEmail = "[email protected]"// must be email
request.customerMobile = "mobile no"//Required
request.customerCivilId = ""
request.mobileCountryIsoCode = MFMobileCountryCodeISO.saudiArabia.rawValue
request.customerReference = ""
request.language = .arabic
let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss")
request.customerAddress = address
request.language = .arabic
request.displayCurrencyIso = .saudiArabia_SAR
let date = Date().addingTimeInterval(1000)
request.expiryDate = date
return request
}


}

Loading

0 comments on commit f36eb50

Please sign in to comment.