Invalid User Credentials in Paypal IOS SDK - ios

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

Related

Stripe Tokenisation Timeout with Apple Pay

I'm following the tutorial here to integrate Apple Pay in a native swift app. I've completed all the steps and am currently attempting to test on a physical device.
Unfortunately the payment fails after a long wait, looking at the network traffic it looks like https://api/stripe.com/v1/tokens is timing out, Please find my code for creating an Apple Pay context below (empty strings are sensitive info that I don't want to share but are usually populated);
private func makePayment() {
let merchantIdentifier = ""
let paymentRequest = Stripe.StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: "GB", currency: "GBP")
paymentRequest.paymentSummaryItems = [
PKPaymentSummaryItem(label: "Payment", amount: amount),
PKPaymentSummaryItem(label: "Service Charge", amount: 0.05),
PKPaymentSummaryItem(label: "", amount: NSDecimalNumber(value: amount.doubleValue + 0.05))
]
guard let context = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) else { return }
context.presentApplePay(completion: nil)
}
I have recreated the merchant ID and certificate etc. and made sure the merchant identifier matches the one on stripe.

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;

How to Send Bitcoin from one Wallet to Another Wallet in Swift 4

I am in the process of developing a custom Bitcoin wallet, I am able to generate the public/private keys by using Yenom/BitcoinKit. I need to send BTC to another wallet for which I am trying to use BitcoinKit. But I could not send Btc. How do I do this? can we use another Library other than BitcoinKit to send Btc from one wallet to another Wallet ?
So how do I transfer BTC from one wallet to another in Swift, please
advise.
Please check the following link
https://github.com/yenom/BitcoinKit/blob/master/Examples/Wallet/Wallet/SendViewController.swift
There is a function called sendToSomeAddress
private func sendToSomeAddress(_ amount: Int64) {
let toAddress: Address = try! AddressFactory.create("bchtest:qpytf7xczxf2mxa3gd6s30rthpts0tmtgyw8ud2sy3")
let changeAddress: Address = try! AppController.shared.wallet!.changeAddress()
var utxos: [UnspentTransaction] = []
for p in payments {
let value = p.amount
let lockScript = Script.buildPublicKeyHashOut(pubKeyHash: p.to.data)
let txHash = Data(p.txid.reversed())
let txIndex = UInt32(p.index)
print(p.txid.hex, txIndex, lockScript.hex, value)
let unspentOutput = TransactionOutput(value: value, lockingScript: lockScript)
let unspentOutpoint = TransactionOutPoint(hash: txHash, index: txIndex)
let utxo = UnspentTransaction(output: unspentOutput, outpoint: unspentOutpoint)
utxos.append(utxo)
}
let unsignedTx = createUnsignedTx(toAddress: toAddress, amount: amount, changeAddress: changeAddress, utxos: utxos)
let signedTx = signTx(unsignedTx: unsignedTx, keys: usedKeys())
peerGroup?.sendTransaction(transaction: signedTx)
}
I hope this will help

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.

Resources