How can I add Amount using Cyber source SDK iOS? - ios

I downloaded Cyber Source SDK iOS from Github. It is also working fine. But I need to set total amount and I can not find any parameter in SDK. How to set amount in Cyber source using SDK?
I don't know it is set by SDK or Backend(API). Please check my code below:
//Card data
let cardData = InAppSDKCardData.init()
cardData.accountNumber = txtCardNumber.text
cardData.expirationMonth = txtMonth.text
cardData.expirationYear = txtYear.text
cardData.cvNumber = txtCVV.text
//Create Transaction object
let transactionObj = InAppSDKTransactionObject.init()
transactionObj.billTo = getBillToData()
transactionObj.cardData = cardData
//Get the Merchant data and credentials and assign.
transactionObj.merchant = getMerchantData()
//Set the End point / Environment. Test or Live
InAppSDKSettings.sharedInstance()?.inAppSDKEnvironment = INAPPSDK_ENV_TEST
//Enable log for debugging
InAppSDKSettings.sharedInstance()?.enableLog = true
//Obtain the gateway sharted instance.
let gatWay = InAppSDKGateway.sharedInstance()
result = (gatWay?.performPaymentDataEncryption(transactionObj, with: self))!
if (result) {
NSLog("InAppSDK: Request Accepted. Expect the response in the delegate method.");
}
else {
NSLog("InAppSDK: Request NOT Accepted. Verify the input values if any one is invalid.");
}
And I got a response like this
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-1623853623"><wsu:Created>2019-08-01T10:25:43.747Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.120"><c:merchantReferenceCode>Cyber_iOS</c:merchantReferenceCode><c:requestID>5646551432976553503004</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AhizbwSTMhmkg5ScYGkcEQFRp++q/94CP9hk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3ND0iLCJ0cmFuc2FjdGlvbklkIjoiNTY0NjU1MTQzMjk3NjU1MzUwMzAwNCJ9LCJzaWduYXR1cmVBbGdJbmZvIjoiU0hBMjU2Iiwic2lnbmF0dXJlIjoiNXdya1BuTEtJZWoxV0ZEVjVZNUJEc0orTUg2QkJSN2Zoa2FVM1ZsQzE2OD0iLCJ2ZXJzaW9uIjoiMS4xLjEuMiJ9</c:data></c:encryptedPayment><c:encryptPaymentDataReply><c:reasonCode>100</c:reasonCode><c:requestDateTime>2019-08-01T10:25:43Z</c:requestDateTime></c:encryptPaymentDataReply><c:reserved><ics_message xmlns="urn:schemas-cybersource-com:transaction-data:ics"><encrypt_payment_data_rcode>1</encrypt_payment_data_rcode><ics_return_code>1000000</ics_return_code><encrypt_payment_data_rmsg>Request was processed successfully.</encrypt_payment_data_rmsg><ics_rcode>1</ics_rcode><encrypt_payment_data_return_code>1001000</encrypt_payment_data_return_code><ics_rmsg>Request was processed successfully.</ics_rmsg><request_id>5646551432976553503004</request_id><encrypt_payment_data.reason_code>100</encrypt_payment_data.reason_code><encrypt_payment_data_rflag>SOK</encrypt_payment_data_rflag><request_token>AhizbwSTMhmkg5ScYGkcEQFRp++q/94CP9hk0ky9GK+AnABMoAny</request_token><ics_decision_reason_code>100</ics_decision_reason_code><encrypt_payment_data_request_date_time>2019-08-01T102543Z</encrypt_payment_data_request_date_time><ics_rflag>SOK</ics_rflag><merchant_ref_number>Cyber_iOS</merchant_ref_number><encrypted_payment_data>eyJkYXRhIjoiK1ZrdmNpTDhpcStyeEt2RytTMDl3R05MbTFGZzlRcXZpQUE3K3FWOFNvckJqYnp1b0lcL3VzRUs0RWpDZkpxZ1pJejJRbWd3cjBNdGxpVXltS2k0bERNS3lFZmdHZmlOS1wvOWRIMWpMXC9WaCszbk5nOXV6NVp2eG54OVpJbmExNkpBbmtvMmt0OSs0S2lDdW1TYkVBVlVtSkdrRm12ZFhqYlBRUXFzVXNcL0xjS2tlVEkzb1RrSkhFXC9jWVBkRXRHZUs1bVErOW8zbDUySWtUb0xPWkJJcUxmeEtcLzNiNUVRY3FcL2ZZOXZJT3l1aFVnZEc2OXVwXC9oQTJJakpORmY1bm1ZcmQ1bkRkVEdEa1EyeGY3RnNGTDdKRjYxdlNUbHljcHIweHFvS09adDNpQVplM1wvR3htT2p1Unp6XC9oTFhsOTZNRFFaUUc1eXZHZHBXaUNydEhRPT0iLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiNDc3NTY5NjQzRDMwMzYzMzYxNjI2MTYzMzYyRDYxMzEzMDMzMkQzNDY2NjY2NTJEMzgzOTYzMzAyRDM4MzczNDY2MzMzNTM1NjI2NTMxNjM2MzNCNDQ2MTc0NjU1NDY5NkQ2NTNEMzIzMDMxMzkyRDMwMzgyRDMwMzE1NDMxMzAzQTMyMzUzQTM0MzMyRTM2MzAzOTM1MzAzNTM4NUEiLCJlcGhlbWVyYWxQdWJsaWNLZXkiOiJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVaRE41dU8rb1R0eXNzdlwvb1V2SjZhQnE1bkVrWVBXZEdDT01sb1YyYkJpaHVROTlHSnBobEk2elwvOHg2M1dmUGpjbGFTcG04ODBJZGNaU0czUkRnNVpRPT0iLCJwdWJsaWNLZXlIYXNoIjoieXRLSjgwc3JjWXppQnVwNzRcL0R5K3RTV1FQSENwXC9ZbkFabGhcL3lXOFk3ND0iLCJ0cmFuc2FjdGlvbklkIjoiNTY0NjU1MTQzMjk3NjU1MzUwMzAwNCJ9LCJzaWduYXR1cmVBbGdJbmZvIjoiU0hBMjU2Iiwic2lnbmF0dXJlIjoiNXdya1BuTEtJZWoxV0ZEVjVZNUJEc0orTUg2QkJSN2Zoa2FVM1ZsQzE2OD0iLCJ2ZXJzaW9uIjoiMS4xLjEuMiJ9</encrypted_payment_data></ics_message></c:reserved></c:replyMessage></soap:Body></soap:Envelope>
Thanks in advance.

This SDK is intended for one purpose - to reduce PCI scope by encrypting the card data which can then be passed to your server. Since it is only encrypting the card data there is no need for an amount.
Once you have the encrypted data you pass that to your server and can then use it to authorize the card. See "Using the Payment Blob" on this page https://github.com/CyberSource/cybersource-ios-sdk. This is the point where you will need the amount. You will also have to pass the amount to your server if it is coming from your iOS App.

Related

Docusign iOS SDK directly sending envelope without opening anything also not asking to do the signature

I have created a template in docusign web and using its template id, i am calling the function from iOS SDK.
TemplatesManager.sharedInstance.displayTemplateForSignature(templateId: templateId, controller: self, tabData: tabData, recipientData: recipientData, customFields:customFields, onlineSign: onlineSign, attachmentUrl: attachmentUrl) { (controller, errMsg) in
print(errMsg)
}
The recipient data i am sending is
let recipientDatum = DSMRecipientDefault()
// Use recipient roleName (other option to use recipient-id) to find unique recipient in the template
recipientDatum.recipientRoleName = "Client"
recipientDatum.recipientSelectorType = .recipientRoleName
recipientDatum.recipientType = .inPersonSigner
// In-person-signer name
recipientDatum.inPersonSignerName = "Akshay Somkuwar"
// Host name (must match the name on the account) and email
recipientDatum.recipientName = "Akshay Somkuwar"
recipientDatum.recipientEmail = "akshay.s.somkuwar#gmail.com"
let recipientData: Array = [recipientDatum]
Same recipient is added for template in docusign website
Also i have added observers for DSMSigningCompleted and DSMSigningCancelled to get envelopeId.
Now when i am calling this function displayTemplateForSignature no screen is opening to show the PDF or To sign the PDF, without asking for signature, the envelope is directly sent to the recipient. and i am getting this response in console with notification.
name = DSMSigningCompletedNotification, object = Optional(<Public_Adjuster.AgreementSignViewController: 0x110bb8060>), userInfo = Optional([AnyHashable("templateId"): 506346f5-7adb-4132-b15f-d288aa268398, AnyHashable("signingMode"): online, AnyHashable("envelopeId"): 2eeeeda8-5b74-4930-904e-94b2ce6451ac])
I want to open the pdf for the passed templateId but its not opening the pdf nor its asking for signature, and its directly sent to the recipient.
Any help will be appreciated, Thank you.
This behaviour, sending the envelope directly, is triggered when DocuSign SDK can not find any signers in the template/envelope that matches the logged-in user. Given that you are using the recipientDefaults, ensure that your signer information on the template (preset signer on the DocuSign web) matches the Account information exactly with the recipientDefaults object.
You may compare it with .
One issue I noticed is the signer type is set to need to sign which corresponds to a remoteSigner on the DocuSign web. And on the recipientDefaults object it's set as inPersonSigner. It should be .signer corresponding to DSMRecipientTypeSigner.
recipientDatum.recipientType = .signer.
Or you may change the need to sign to in person signer on the DocuSign web.
Another suggestion is to remove the name & email from the template screenshot shared and keep that empty as the client app is passing name & email with the recipientDefaults object to the SDK.
More details: How to set recipient defaults

Cannot set PubNub auth key Swift iOS

I have a webapp and the iOS app built in Swift. The thing is I don't know Swift and I'm trying to modify the iOS app in order to add the authorization key to the PubNub client before subscribing/publishing to channels.
Link to PubNub docs
PRE:
Access Manager is enabled
my_auth_key is hardcoded and already enabled form the server for the corresponding channel I want to subscribe.
Here is the code
What's the correct way to set the auth key?
Thanks in advance
Polak, mentioned docs code snippet refer to previously created instance to get it's pre-configured PNConfiguration instance and change required field. This practice can be used in case if you need change something at run-time.
If you have data for authKey at the moment of client initialization, you can set it:
var pubnubClient: PubNub = {
let configuration = PNConfiguration(publishKey: UCConstants.PubNub.publishKey, subscribeKey: UCConstants.PubNub.subscribeKey)
configuration.authKey = "my_auth_key"
return PubNub.clientWithConfiguration(configuration)
}()
Also, I've tried exact your code and don't have any issues with setting of authKey, because I can see it with subscribe request.
If you still will have troubles with PAM and auth key usage, please contact us on support#pubnub.com
Looks like you can:
let configuration = PNConfiguration(
authKey: "super_secret",
publishKey: UCConstants.PubNub.publishKey,
subscribeKey: UCConstants.PubNub.subscribeKey
)
Based on the Obj-C code: https://github.com/pubnub/objective-c/blob/8c1f0876b5b34176f33681d22844e8d763019635/PubNub/Data/PNConfiguration.m#L174-L181

NEVPNManager - Connect on-demand blocks internet access

I'm creating a VPN profile through my app and I have the following rules and set up:
let newIPSec = NEVPNProtocolIPSec()
newIPSec.serverAddress = AppConfiguration.getVPNEndPoint()
newIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.sharedSecret
newIPSec.username = VPNCredentialsModel.instance.vpnUserName()
newIPSec.passwordReference = VPNCredentialsModel.instance.vpnPasswordReference() as Data?
newIPSec.sharedSecretReference = VPNCredentialsModel.instance.vpnPresharedKeyReference() as Data?
newIPSec.useExtendedAuthentication = true
newIPSec.disconnectOnSleep = false
self.manager.protocolConfiguration = newIPSec
let connectRule = NEOnDemandRuleConnect()
connectRule.interfaceTypeMatch = .any
let ignoreRule = NEOnDemandRuleIgnore()
ignoreRule.interfaceTypeMatch = .any
ignoreRule.probeURL = URL(string:probeURL)
self.manager.onDemandRules = [ignoreRule,connectRule]
self.manager.isOnDemandEnabled = true
self.manager.isEnabled = true
Update
My probeURL is a rest API call which updates the backend and returns 200 or 500 based on the user status. There is some latency since there are some sql querying being carried out. The probeURL expects a 200 OK else invalidates the ignore rule. The ignore rule becomes invalid and it tries to connect to the VPN but the user can't connect anymore since the VPN blocked the user. The iOS device keeps trying in an infinite loops and blocks the internet access from other applications pushing the device to a brick state. Is there a better way to handle this case?
Suggestion
I can update the DB with a file endpoint that points the user status like a flag - (each user has a file endpoint). If the file is available it returns a 200 OK and if its removed returns 404. This way probe url can receive a 200 OK with no latency when needed. However this might be an extra layer of implementation and file management. Whats your view on this? Can someone recommend a better way to handle this test case?
Testing
I was testing a successful scenario with the following probe URL:
httpstat.us/200 for ignoreRule to be valid and not connect
httpstat.us/500 for ignoreRUle to be invalid and continue connecting to the VPN

OVER_QUERY_LIMIT in simple SPGooglePlacesAutocompleteQuery request

I'm trying to create simple autocomplete UI widget:
self.autocompleteQuery = [[SPGooglePlacesAutocompleteQuery alloc] initWithApiKey:[GlobalConfig sharedInstance].kGoogleBrowserKey];
self.autocompleteQuery.language = kFFAutocompleteQueryLanguage;
self.autocompleteQuery.types = SPPlaceTypeAddress;
self.autocompleteQuery.location = [FFAppDataHelper coordinatesForMoscow];
self.autocompleteQuery.radius = [GlobalConfig sharedInstance].kMoscowRadius;
self.autocompleteQuery.countryCode = #"RU";
Then I want to get all values for input string from UITextField on 'valueChanged' event:
self.autocompleteQuery.input = [streetName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[self.autocompleteQuery fetchPlaces:^(NSArray *places, NSError *error) {
[self loaderStopAnimating];
if (places) {
//do some stuff
} else {
FFError *detectedError = [FFError errorWithNSError:error];
[self showErrorMessage:[detectedError errorMessage]];
}
}];
So when I type 'k' I get response with streets and if I add next char to my text field I receive OVER_QUERY_LIMIT every time. I've tried it on simulator and devices with the same result. And it starts working again after 10-20 sec. I don't use loops or smth similar, I just want to get suggestions for input string in real time, but I can't get it because of error. What should I do to avoid it?
For the web service request, use a key.
Follow this :https://developers.google.com/maps/documentation/geocoding/start#api_key
Doc says:
Note: Maps for Work users must include client and signature parameters with their requests instead of a key.
All Geocoding API applications should use an API key. Including a key in your request:
Allows you to monitor your application's API usage in the Google Developers Console. Enables per-key instead of per-IP-address quota limits. Ensures that Google can contact you about your application if necessary. The Geocoding API uses an API key to identify your application. API keys are managed through the Google APIs console. To create your key:
Visit the APIs console at Google Developers Console and log in with your Google Account. Click the Services link from the left-hand menu in the APIs Console, then activate the Geocoding API service. Once the service has been activated, your API key is available from the API > Access page, in the Simple API Access section. Geocoding API applications use the Key for server apps. To specify a key in your request, include it as the value of a key parameter.
Note: By default, a key can be used from any server. We strongly recommend that you restrict the use of your key by IP address to servers that you administer. You can specify which IP addresses are allowed to use your API key by clicking the Edit allowed referers... link in the API console.
Note: HTTPS is enforced for requests that include an API key.

Blackberry smartcard reader example

I am writing an app for BlackBerry that utilizes a BlackBerry smartcard reader. There is not much documentation on the subject, so I'd really like if someone could give me starting examples.
Basically, there is one RSA private key on the card plus a certificate (for paired public key). I would like to be able to encrypt/decrypt data and also sign it as well. The final goal would be to establish an mutual-authenticated SSL connection using client certificate contained on the smartcard.
Here is the code I managed to come up with so far:
SmartCardReader btReader = null;
SmartCardReader[] readers = SmartCardReaderFactory.getInstalledReaders();
for (int i = 0; i < readers.length; i++) {
SmartCardReader reader = readers[i];
if (reader.getType().equalsIgnoreCase("bluetooth")) {
btReader = reader;
break;
}
}
SmartCardReaderSession readerSession = reader.openSession();
CryptoSmartCard card = (CryptoSmartCard) readerSession.getSmartCard();
RSACryptoToken token = (RSACryptoToken) card.getCryptoToken("RSA");
This token looks promising - has some nice methods, but with "cryptic" arguments. What to do next?
I think this is what you are looking for:
http://code.google.com/p/seek-for-android/wiki/BTPCSC
You have to implement SmartCardSession methods, also implement RSACryptoToken methods.
With SmartCardSession methods you will be able to communicate with smart card, and with RSACryptoToken methods, you will be able to perform crypto operations.
You have to read also about APDU protocol.

Resources