ApplePay issue - Payment not Completed - ios

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;

Related

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)")
}
```

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

PKPaymentAuthorizationViewController(paymentRequest: requestObject) is returning nil

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.

How to initialise a AWSCognitoIdentityUserAttributeType in Swift?

I'm very new to iOS/Swift development. I'm trying to implement user signup/signin using AWS Cognito. After initialising the SDK with a default configuration I do:
let pool = AWSCognitoIdentityUserPool(forKey: "UserPool")
[followed by]
pool.signUp(...)
to register a user.
I need to pass and array of AWSCognitoIdentityUserAttributeType to the signUp method, but I'm unable to initialise objects of this type.
var first_name = AWSCognitoIdentityUserAttributeType(
dictionary: ["given_name": "rob"])
results in the following Error:
2016-07-10 08:48:43.025 Demo1[4199:111322] -
[AWSCognitoIdentityUserAttributeType initWithDictionary:]:
unrecognized selector sent to instance 0x7fee54a6ede0
I Belive you should do like this, create an Array of AWSCognitoIdentityUserAttributeType, then create a bunch of objects of that type, assign the 'name' then the 'value' as I did below. Then you can use that object 'attributes' in your pool.signup
var attributes = [AWSCognitoIdentityUserAttributeType]()
let name = AWSCognitoIdentityUserAttributeType()
let email = AWSCognitoIdentityUserAttributeType()
let gender = AWSCognitoIdentityUserAttributeType()
let birthdate = AWSCognitoIdentityUserAttributeType()
let username = AWSCognitoIdentityUserAttributeType()
let myFormatter = DateFormatter()
myFormatter.dateFormat = "dd/MM/yyyy"
name?.name = "name"
email?.name = "email"
gender?.name = "gender" //implementar genero ainda
birthdate?.name = "birthdate"
sobrenome?.name = "family_name"
username?.name = "preferred_username"
let birthdateNsDate:Date = birthdateField.date as Date
birthdate?.value = myFormatter.string(from: birthdateNsDate)
name?.value = nameTextField.text!
email?.value = emailTextField.text!
attributes.append(name!)
attributes.append(email!)
attributes.append(gender!)
attributes.append(birthdate!)
attributes.append(sobrenome!)
attributes.append(username!)
Following snippet demonstrates how to use
AWSCognitoIdentityUserAttributeType * phone = [AWSCognitoIdentityUserAttributeType new];
phone.name = #"phone_number";
//phone number must be prefixed by country code
phone.value = #"+15555555555";
AWSCognitoIdentityUserAttributeType * email = [AWSCognitoIdentityUserAttributeType new];
email.name = #"email";
email.value = #"email#mydomain.com";
//sign up the user
[[pool signUp:#"username" password:#"password" userAttributes:#[email,phone] validationData:nil] continueWithBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserPoolSignUpResponse *> * _Nonnull task) {
dispatch_async(dispatch_get_main_queue(), ^{
if(task.error){
[[[UIAlertView alloc] initWithTitle:task.error.userInfo[#"__type"]
message:task.error.userInfo[#"message"]
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil] show];
}else {
AWSCognitoIdentityUserPoolSignUpResponse * response = task.result;
if(!response.userConfirmed){
//need to confirm user using user.confirmUser:
}
}});
return nil;
}];
Following link describes usage of User Pools with the iOS SDK:
https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-ios-sdk.html
A single instance:
e.g.,
AWSCognitoIdentityUserAttributeType(name: "key", value: "string")
An array as a parameter in a function call:
awsUserPool.currentUser()?.update([
AWSCognitoIdentityUserAttributeType(name: "key0", value: string0),
AWSCognitoIdentityUserAttributeType(name: "key1", value: string1)
])
Values need to be converted to a String. E.g.,
AWSCognitoIdentityUserAttributeType(name: "key", value: "\(number)")

RTCDataChannel not working iOS

I'm using RTCDataChannel. But messages which i'm sending through the channel are not receiving at the other peer.
Here is the code:
let audioConstraint : RTCPair = RTCPair(key: "OfferToReceiveAudio", value: "true")
let videoConstraint : RTCPair = RTCPair(key: "OfferToReceiveVideo", value: "true")
let dtlsConstraint : RTCPair = RTCPair(key: "DtlsSrtpKeyAgreement", value: "true")
let mediaContraints : RTCMediaConstraints = RTCMediaConstraints(mandatoryConstraints: [audioConstraint, videoConstraint], optionalConstraints: [ dtlsConstraint])
RTCPeerConnectionFactory.initializeSSL()
peerConnection = peerConnectionFactory.peerConnectionWithICEServers(servers, constraints: mediaContraints, delegate: self)
dataChannels = peerConnection?.createDataChannelWithLabel(channelName,config: nil)
dataChannels?.delegate = self
var message : NSData = NSData(base64EncodedString: "helloo")
var buffer : RTCDataBuffer = RTCDataBuffer(data: message, isBinary: true)
dataChannels?.sendData(buffer)
Have you resolved it?
One of the two peers should create data channel and other should attach the received data channel object to its data channel object.
The initiator should create datachannel before sending offer. Hope this might be helpful
I had the same problem until I set the option not to nil. If I skipped the steamId, it would not send. Even though the channel is open.
RTCDataChannelInit *dataInit = [[RTCDataChannelInit alloc] init];
dataInit.isNegotiated = YES;
dataInit.isOrdered = YES;
dataInit.maxRetransmits = 30;
dataInit.maxRetransmitTimeMs = 30000;
dataInit.streamId = 12; //important setting
self.dataChannel = [_peerConnection createDataChannelWithLabel:kRTCDataChannelLabel config:dataInit];
self.dataChannel.delegate = self;

Resources