PKPaymentAuthorizationViewController(paymentRequest: requestObject) is returning nil - ios

I am facing a problem in initilizing PKPaymentAuthorizationViewController returning nil in one of the device.
The device region is set to UK and I have added a UK issued card in the Apple Wallet.
The PKPaymentRequest is configured as following:
let request = PKPaymentRequest()
request.merchantIdentifier = "mymerchantid"
request.supportedNetworks = [PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex]
request.merchantCapabilities = PKMerchantCapability.Capability3DS
request.countryCode = "US"
request.currencyCode = "USD"
let price: <NSDecimalNumber>
let item : PKPaymentSummaryItem = PKPaymentSummaryItem(label: "amount", amount: price, type: .Pending)
request.paymentSummaryItems = [
item
]
let paymentAuthorizationVC = PKPaymentAuthorizationViewController(paymentRequest: request) // Returning Nil
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(SupportedPaymentNetworks) // Returns true
Device: iPhone 6
OS: 10.2.2
Note: Same Card is onboared in another device for the same App its working fine.
Tried as mentioned in the below link and few other blogs- no luck
Apple pay PKPaymentauthorizationViewController always returning nil when loaded with Payment request
Looking for suggestions.

I had this same problem and the cause was using a Discover card for testing when it's not included as a supported payment network. Make sure that you are passing in all the credit card types that your user base will possibly use.
Try changing this line:
request.supportedNetworks = [PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex]
To the following:
request.supportedNetworks = [PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex, PKPaymentNetwork.discover]
In Swift3, The declaration for PKPaymentAuthorizationViewController init() is not defined as optional, even though it does return nil when it fails.

Related

ApplePay issue - Payment not Completed

After creating PKPaymentRequest I try to make a payment and always get the same error on the UI - Payment not completed. The delegate method is never called so I could not even understand what is the problem.
Initializing PKPayemntRequest is:
request.merchantIdentifier = "MY MERCHANT ID"
request.countryCode = countryCode
request.currencyCode = currency
request.supportedNetworks = [.visa, .masterCard, .amex]
if #available(iOS 12.0, *) { request.supportedNetworks.append(.maestro) }
request.paymentSummaryItems = [PKPaymentSummaryItem(label: "Transaction text", amount: NSDecimalNumber(decimal: amount))]
request.merchantCapabilities = .capabilityCredit
Maybe you must support 3DS; support of EMV is optional.
Like:
request.merchantCapabilities = PKMerchantCapabilityEMV | PKMerchantCapability3DS;

Invalid User Credentials in Paypal IOS SDK

I am getting the Invalid user credentials when i am trying to log in with paypal id. I am sure i have entered the correct client ID of the live account and its working successfully on Sandbox
PayPal SDK: Request has failed with error: invalid_user - Incorrect username/password. Please try again。 (401) |
PayPal Debug-ID: b2cedad5b6842, b2cedad5b6842 [live, PayPal iOS SDK 2.16.2] |
Details: (
{
"error_description" = "Invalid user credential";
}
).
I have entered the correct live client ID. and have made the environment to production cant get this done please help here is my code below in my app delegate:
```
//TODO: – Enter your credentials
PayPalMobile .initializeWithClientIds(forEnvironments: [PayPalEnvironmentProduction:
"**********************************-s_8AiXkLD1NA********"
])
var payPalConfig = PayPalConfiguration()
in viewDidLoad:
//=======Paypal Configuration========================================================================
// Set up payPalConfig
payPalConfig.acceptCreditCards = true
payPalConfig.merchantName = "Donation to Edhi"//Give your company name here.
payPalConfig.merchantPrivacyPolicyURL = URL(string: "“https://www.paypal.com/webapps/mpp/ua/privacy-full”")
payPalConfig.merchantUserAgreementURL = URL(string: "“https://www.paypal.com/webapps/mpp/ua/useragreement-full”")
//This is the language in which your paypal sdk will be shown to users.
payPalConfig.languageOrLocale = Locale.preferredLanguages[0]
//========== un comment line below to make paypal live==============
// environment = PayPalEnvironmentProduction
//====================================================================
//Here you can set the shipping address. You can choose either the address associated with PayPal account or different address. We’ll use .both here.
payPalConfig.payPalShippingAddressOption = .both;
This is what i have in my function
//These are the items choosen by user, for example
let item1 = PayPalItem(name: donationTypeTxt! , withQuantity: 1, withPrice:
NSDecimalNumber(string: totalPaypalAmount), withCurrency: "AUD", withSku: "don-001")
let items = [item1]
let subtotal = PayPalItem.totalPrice(forItems: items) //This is the total price of all
the items
// Optional: include payment details
let shipping = NSDecimalNumber(string: "0.00")
let tax = NSDecimalNumber(string: "0.00")
let paymentDetails = PayPalPaymentDetails(subtotal: subtotal, withShipping: shipping,
withTax: tax)
let total = subtotal.adding(shipping).adding(tax) //This is the total price including
shipping and tax
let payment = PayPalPayment(amount: total, currencyCode: "AUD", shortDescription: "3%
Merchant fee is included.", intent: .sale)
payment.items = items
payment.paymentDetails = paymentDetails
// var newamount: NSDecimalNumber = NSDecimalNumber(totalDonationAmount!) as!
NSDecimalNumber
if (payment.processable) {
let paymentViewController = PayPalPaymentViewController(payment: payment,
configuration: payPalConfig, delegate: self)
paymentViewController!.modalPresentationStyle = .fullScreen
present(paymentViewController!, animated: true, completion: nil)
}
else {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn’t be processable, and you’d want
// to handle that here.
print("Payment not processalbe: (payment)")
}
```

Sign any message with the user’s private key and verify the signature on Ethereum

I'm trying to explore Ethereum and creating a app which let user sign message and validate the message.
I'm using web3swift framework for this and what I have tried so far is as follows -
let web3Rinkeby = Web3.InfuraRinkebyWeb3()
let msgStr = "This is my first Ethereum App";
let data = msgStr.data(using: .utf8)
let signMsg = web3Rinkeby.wallet.signPersonalMessage(data!, account: address);
print(signMsg);
but I'm not sure if this is right and how to validate any message as well. Please help.
Seems, that you didn't specify exact address.
Here is an example:
let web3Rinkeby = Web3.InfuraRinkebyWeb3()
///
let keystore = try! EthereumKeystoreV3(password: "")
let keystoreManager = KeystoreManager([keystore!])
web3Rinkeby.addKeystoreManager(keystoreManager)
let address = keystoreManager.addresses![0]
///
let msgStr = "This is my first Ethereum App";
let data = msgStr.data(using: .utf8)
let signMsg = web3Rinkeby.wallet.signPersonalMessage(data!, account: address);
print(signMsg);
Here is an example, how to sign transactions in the tests of the project:

PayTM SDK : Transaction Failed

I am integrating PayTM in my app which is in ios (Swift) and I am facing issue which title is "Transaction Failed" and the message is "MissingKeys"
I have used following code
merchant = PGMerchantConfiguration.default()!
merchant.checksumGenerationURL = "http://getlook.in/cgi-bin/checksum_generate.cgi"
merchant.checksumValidationURL = "http://getlook.in/cgi-bin/checksum_validate.cgi"
merchant.clientSSLCertPath = nil
merchant.clientSSLCertPassword = nil
merchant.merchantID = "rriver57770575448885"
merchant.website = "APP_STAGING"
merchant.industryID = "Retail"
merchant.channelID = "WAP"
var orderDict = [String: String]()
orderDict["MID"] = "rriver57770575448885" // Merchant ID
orderDict["CHANNEL_ID"] = "WAP" // Channel Id
orderDict["INDUSTRY_TYPE_ID"] = "Retail" // Industry Type
orderDict["WEBSITE"] = "APP_STAGING"
orderDict["TXN_AMOUNT"] = "10"; // amount to charge // mandatory
orderDict["ORDER_ID"] = "\(Date().timeIntervalSince1970)";//change order id every time on new transaction
orderDict["REQUEST_TYPE"] = "DEFAULT";// remain same
orderDict["CUST_ID"] = "123456789027"; // change acc. to your database user/customers
orderDict["MOBILE_NO"] = "8798987874";// optional
orderDict["EMAIL"] = "test#paytm.com"; //optional
let pgOrder = PGOrder(params: orderDict)
let transaction = PGTransactionViewController.init(transactionFor: pgOrder)
transaction?.serverType = eServerTypeProduction
transaction?.merchant = merchant
transaction?.loggingEnabled = true
transaction?.delegate = self
self.present(transaction!, animated: true, completion: nil)
please help!
In this code you have missed a parameter called chechSumHash. include that too.
orderDict["CHECKSUMHASH"] = CheckSum;
checkSumHash can be generated in the backend by the help of Paytm checksum generation kit. the checksum is a unique string which will change according to the parameter that we have send for checksum generation Api

TouchID with KeyChain - Enter Passcode screen appears malformed (Swift)

I am having a hard time with this one:
Our app uses TouchID to retrieve secrets from the KeyChain that are used to authenticate to a WebApp in a WKWebView. All is fine when the user successfully authenticates with TouchID.
The problem arises when the user fails TouchID and then taps on "Enter Passcode" to authenticate via device passcode instead. I noticed that the screen that gets presented is plain white, and the passcode text-box does not show a value for the last character entered until it is masked, creating a strange user experience. This seems like a bug to me, unless I am somehow missing a configuration requirement.
// global arguments for the touchId keychain queries
let kSecClassValue = NSString(format: kSecClass)
let kSecAttrAccountValue = NSString(format: kSecAttrAccount)
let kSecValueDataValue = NSString(format: kSecValueData)
let kSecClassGenericPasswordValue = NSString(format: kSecClassGenericPassword)
let kSecAttrServiceValue = NSString(format: kSecAttrService)
let kSecMatchLimitValue = NSString(format: kSecMatchLimit)
let kSecReturnDataValue = NSString(format: kSecReturnData)
let kSecMatchLimitOneValue = NSString(format: kSecMatchLimitOne)
let kSecAttrAccessControlValue = NSString(format: kSecAttrAccessControl)
let kSecUseOperationPromptValue = NSString(format: kSecUseOperationPrompt)
// set access control
let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, .UserPresence, nil)
// Instantiate a new default keychain query
// Tell the query to return a result
// Limit our results to one item
var keychainQuery: NSMutableDictionary = NSMutableDictionary(objects: [kSecClassGenericPasswordValue, service, userAccount, kCFBooleanTrue, kSecMatchLimitOneValue, "Place your finger to authenticate.", accessControl.takeUnretainedValue()], forKeys: [kSecClassValue, kSecAttrServiceValue, kSecAttrAccountValue, kSecReturnDataValue, kSecMatchLimitValue, kSecUseOperationPromptValue, kSecAttrAccessControlValue])
var dataTypeRef :Unmanaged<AnyObject>?
// Search for the keychain item
touchIdStatusCode = SecItemCopyMatching(keychainQuery, &dataTypeRef)
Here is the generated keychainQuery dictionary:
{
"accc" = "<SecAccessControlRef: 0x170621140>";
"acct" = “MY_ACCOUNT”;
"class" = genp;
"m_Limit" = "m_LimitOne";
"r_Data" = 1;
"svce" = “MY_SERVICE”;
"u_OpPrompt" = "Place your finger to authenticate.";
}
This behavior exists on the latest iOS version (8.4). Here is the screen I was referring to:
My question is: Am I somehow causing the screen to be broken by the way I am invoking TouchID? Or is this perfectly normal for this scenario?
Thanks, and sorry for the lengthy post!
The issue described is a bug that was confirmed by Apple engineers. It still exists as of iOS 9.0.2.

Resources