Advertisement
rahat14

SSL

Jul 13th, 2021
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.12 KB | None | 0 0
  1. //
  2. //  AddressPaymentViewModel.swift
  3. //  Afiq Souq
  4. //
  5. //  Created by GAMEKILLER on 4/12/21.
  6. //
  7.  
  8. import Foundation
  9. import RealmSwift
  10. import SSLCommerzSDK
  11. import UIKit
  12. class AddressPaymentViewModel: ObservableObject , SSLCommerzDelegate {
  13.     //class AddressPaymentViewModel: ObservableObject{
  14.     var ssl: SSLCommerz?
  15.     var totalAmount : Double = 0.0
  16.     var delivery_address : String = ""
  17.     var name  : String = ""
  18.     var ph : String = ""
  19.    
  20.     init(total_amount : String , isCodeUsed : Bool , code : String) {
  21.        
  22.         self.totalAmount = Double(total_amount) ?? 0.0
  23.         self.CouponCode = code
  24.         self.iCodeUsed = isCodeUsed
  25.         getDeliveryAddress()
  26.        
  27.     }
  28.    
  29.  
  30.         func createPayment() {
  31.        
  32.        
  33.         let user = loadUser()
  34.        
  35.         let  transID = currentTimeInMilliSeconds()
  36.        
  37.         ssl = SSLCommerz.init(integrationInformation: .init(storeID: STORE_ID, storePassword: STORE_PASS,
  38.                                                             totalAmount: totalAmount, currency: "BDT", transactionId: transID, productCategory: "product"),
  39.                               emiInformation: nil, customerInformation: .init(customerName: user?.firstName ?? "cus", customerEmail:
  40.                                                                                 user?.email ?? "cus", customerAddressOne: user?.billing.address1 ?? "cus", customerCity: user?.billing.city ?? "cus", customerPostCode: "111",
  41.                                                                               customerCountry: "BD", customerPhone: user?.billing.phone ?? "cus"), shipmentInformation: nil,
  42.                               productInformation: nil, additionalInformation: nil)
  43.        
  44.        
  45.         ssl?.delegate = self
  46.        
  47.         ssl?.start(in: (UIApplication.shared.windows.first?.rootViewController)!, shouldRunInTestMode: false)
  48.        
  49.     }
  50.  
  51.     func transactionCompleted(withTransactionData transactionData: TransactionDetails?){
  52.        
  53.        
  54.      
  55.         CreateOrder(isPaid: true, method: "ssl")
  56.        
  57.     }
  58.    
  59.    
  60.    
  61.    
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement