iOS PayUMoney SDK-key is not valid - ios

I have integrate payumoney payment gateway. And I am able to create correct hash with the key, but at the end am getting an alert message as "key is not valid".what would be the problem?
Here is the code. I use the link "https://www.payumoney.com/payment-gateway-integration-guide.html" to download the payumoney SDK.
- (IBAction)startPaymentTapped:(id)sender {
[self setPaymentParameters];
//Start the payment flow
PUMMainVController *paymentVC = [[PUMMainVController alloc] init];
UINavigationController *paymentNavController = [[UINavigationController alloc] initWithRootViewController:paymentVC];
[self presentViewController:paymentNavController
animated:YES
completion:nil];
}
- (void)setPaymentParameters {
self.params = [PUMRequestParams sharedParams];
self.params.environment = PUMEnvironmentProduction;
self.params.amount = self.amount.text;
self.params.key = #"mykeyvalue";
self.params.merchantid = #"merchantid";
self.params.txnid = [self getRandomString:2];
self.params.surl = #"https://www.payumoney.com/mobileapp/payumoney/success.php";
self.params.furl = #"https://www.payumoney.com/mobileapp/payumoney/failure.php";
self.params.delegate = self;
self.params.firstname = self.firstname.text;
self.params.productinfo = self.productinfo.text;
self.params.email = self.email.text;
self.params.phone = #"";
self.params.udf1 = #"";
self.params.udf2 = #"";
self.params.udf3 = #"";
self.params.udf4 = #"";
self.params.udf5 = #"";
self.params.udf6 = #"";
self.params.udf7 = #"";
self.params.udf8 = #"";
self.params.udf9 = #"";
self.params.udf10 = #"";
self.params.hashValue = [self getHash];
}
- (NSString *)getRandomString:(NSInteger)length {
NSMutableString *returnString = [NSMutableString stringWithCapacity:length];
NSString *numbers = #"0123456789";
// First number cannot be 0
[returnString appendFormat:#"%C", [numbers characterAtIndex:(arc4random() % ([numbers length]-1))+1]];
for (int i = 1; i < length; i++) {
[returnString appendFormat:#"%C", [numbers characterAtIndex:arc4random() % [numbers length]]];
}
return returnString;
}
- (NSString*)getHash {
NSString *hashSequence = [NSString stringWithFormat:#"mykeyvalue|%#|%#|%#|%#|%#|||||||||||salt",self.params.txnid, self.params.amount, self.params.productinfo,self.params.firstname, self.params.email];
NSString *rawHash = [[self createSHA512:hashSequence] description];
NSString *hash = [[[rawHash stringByReplacingOccurrencesOfString:#"<" withString:#""]stringByReplacingOccurrencesOfString:#">" withString:#""]stringByReplacingOccurrencesOfString:#" " withString:#""];
return hash;
}
- (NSData *) createSHA512:(NSString *)source {
const char *s = [source cStringUsingEncoding:NSASCIIStringEncoding];
NSData *keyData = [NSData dataWithBytes:s length:strlen(s)];
uint8_t digest[CC_SHA512_DIGEST_LENGTH] = {0};
CC_SHA512(keyData.bytes, (CC_LONG)keyData.length, digest);
NSData *output = [NSData dataWithBytes:digest length:CC_SHA512_DIGEST_LENGTH];
NSLog(#"out --------- %#",output);
return output;
}

Please check data when you send payumoney for create hash key with server api data for create your hash key.

self.params.environment = PUMEnvironmentProduction;
Through the above code you can pay using net banking successfully. If you want to test
your payment gateway for dummy credit/debit card some changes are required. I am
listing it down. Try it.
Instead of
self.params.environment = PUMEnvironmentProduction; //write
self.params.environment = PUMEnvironmentTest;
change the urls as
self.params.surl = #"https://test.payumoney.com/mobileapp/payumoney/success.php";
self.params.furl = #"https://test.payumoney.com/mobileapp/payumoney/failure.php";
// We need test url for testing purpose.
Make sure you have activated your payumoney account by clicking on link that you got in mail.
Use the below dummy master card details
Test Card Name: any name
Test Card Number: 5123456789012346
Test CVV: 123
Test Expiry: May 2017

Related

iOS: How to separate key values in multiple dictionary which is in one array?

i haveNSDictionary like this:
(
{
bp = "158/56";
dateTime = "05/12/2016 11:51:12 AM";
doc = {
"email_id" = "gkalal64#gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8149910113;
name = Kabadia;
"profile_id" = 0;
qualification = MBBS;
"reg_id" = 100;
salutation = Mr;
"wellness_id" = IN8S2D29A2;
};
"follow_up" = 14;
id = 6;
medicine = (
"Injection,Crocin,5,0-1-0,After Meal,2",
"Powder,churan,10,1-0-0,Before Meal,14",
no,
no,
no,
no,
no,
no,
no,
no
);
patient = {
"email_id" = "bishtrohit1989#gmail.com";
exception = 0;
gender = Male;
id = 0;
"mobile_no" = 8624088776;
name = kamlesh;
"profile_id" = 0;
qualification = "";
"reg_id" = 101;
salutation = Mr;
"wellness_id" = IND16HRR65;
};
weight = 47;
}
)
I want to display above information like following way:
But i have no idea about how to do that. i searched for this but i didn't get exactly how to do this.
What i did:
In previous View controller i have displayed multiple prescription title. after click on particular cell, i called this view and i got above response from server, which i want to display like above image.
I have taken UITableView on screen for this.
I have taken 1 static custom cell for this.
But i don't know how to do.
Please anyone can solve my issue. help will be appreciable.
As per your data structure i guess your data is kind of single object so it's clear that its not a collection(array) of same kind of object so i would suggest you to create only single custom cell for this entire single record.
In this case your TableView will have only single row.
In the Custom cell: lets call it 'PatientDetail'
Add all the labels and controls which you want to show for each
property and connect outlets whatever is required.
If you are using an Autolayout then give relative constraints to all the controls else set frame of each control dynamically by calculating the height of it's content.
How it will work ?
As you said its detail screen of particular list so we will show single row in tableview with all the details in it.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
In the follwing code
responseDict the NSDictionary which is the first object of response as your response is kind of array.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PatientDetail *cell=[tableView dequeueReusableCellWithIdentifier:#"PatientDetail" forIndexPath:indexPath];
//Setting
[cell.lbDateTime setText:[responseDict valueForKey:#"dateTime"]];
//Doctor name Just
[cell.lbDoctorName setText:[[responseDict objectForKey:#"doc"]valueForKey:#"name"]];
//Follow the above steps for all the details
return cell;
}
Updated Answer
if (indexPath.row < responseArray.count){
NSString *docName = #"";
NSString *contact = #"";
NSString *wellness_id = #"";
if ([selectedDict valueForKey:#"doc"] != nil){
NSDictionary *doctorDict = [selectedDict valueForKey:#"doc"];
NSString *lDocName = [doctorDict valueForKey:#"name"];
if(lDocName.length > 0){
docName = lDocName;
}
NSString *qulification = [doctorDict valueForKey:#"qualification"];
if(qulification.length > 0){
docName = [NSString stringWithFormat:#"%# %#", docName, qulification];
}
NSString *mobile_no = [doctorDict valueForKey:#"mobile_no"];
if(mobile_no.length > 0){
contact = mobile_no;
}
NSString *email_id = [doctorDict valueForKey:#"email_id"];
if(email_id.length > 0){
contact = [NSString stringWithFormat:#"%# / %#", contact, email_id];
}
NSString *wellness_idTemp = [doctorDict valueForKey:#"wellness_id"];
if(wellness_idTemp.length > 0){
wellness_id= [NSString stringWithFormat:#"Wellness_Id : %#", wellness_idTemp];
}
}
cell.docNameLabel.text = docName;
cell.contact.text = contact;
cell.wellnessID.text = wellness_id;
NSString *patientName = #"";
NSString *patientcontact = #"";
NSString *patientWellness_id = #"";
NSString *bloodPressure = [selectedDict valueForKey:#"bp"];
NSString *weight = [selectedDict valueForKey:#"weight"];
if ([selectedDict valueForKey:#"patient"] != nil){
NSDictionary *patientDict = [selectedDict valueForKey:#"patient"];
NSString *lName = [patientDict valueForKey:#"name"];
if(lName.length > 0){
patientName = lName;
}
NSString *mobile_no = [patientDict valueForKey:#"mobile_no"];
if(mobile_no.length > 0){
patientcontact = mobile_no;
}
NSString *email_id = [patientDict valueForKey:#"email_id"];
if(email_id.length > 0){
patientcontact = [NSString stringWithFormat:#"%# / %#", contact, email_id];
}
NSString *wellness_idTemp = [patientDict valueForKey:#"wellness_id"];
if(wellness_idTemp.length > 0){
patientWellness_id = [NSString stringWithFormat:#"Wellness Id : %#", wellness_idTemp];
}
}
cell.patientNameLabel.text = patientName;
cell.contact.text = patientcontact;
cell.wellnessID.text = wellness_id;
cell.bp.text = bloodPressure;
cell.weight.text = weight;
}
Hope this will help.

How to separate NSString with multiple commas?

Am having this nsstring
NSString * countryStr = #"6023117,159,en_US,Seychelles,SC,Seychelles,6023185,95,en_US,Kuwait,KW,Kuwait,6023182,172,en_US,Swaziland,SZ,Swaziland,6023185,157,en_US,Saudi Arabia,SA,Saudi Arabia,6023182,177,en_US,Tanzania,TZ,Tanzania,6023185,179,en_US,Togo,TG,Togo,6023185,87,en_US,Cote d'Ivoire,CI,Cote d'Ivoire";
now i want to display only the countries which are suffixed by "en_US".
can anybody tell me how to split that string to get the countries.
I did like this
NSError * error;
NSString* imageName = [[NSBundle mainBundle] pathForResource:#"CountryList" ofType:#"txt"];
NSString * countrStr = [NSString stringWithContentsOfFile:imageName encoding:NSStringEncodingConversionAllowLossy error:&error];
NSArray * dfd = [countrStr componentsSeparatedByString:#"en_US"];
for(int i=0;i<dfd.count;i++)
{
NSString * nama = [dfd objectAtIndex:1];
NSArray * djk = [nama componentsSeparatedByString:#","];
NSString * aksjd = [djk objectAtIndex:1];
}
You can do it like this;
NSString * countryStr = #"6023117,159,en_US,Seychelles,SC,Seychelles,6023185,95,en_US,Kuwait,KW,Kuwait,6023182,172,en_US,Swaziland,SZ,Swaziland,6023185,157,en_US,Saudi Arabia,SA,Saudi Arabia,6023182,177,en_US,Tanzania,TZ,Tanzania,6023185,179,en_US,Togo,TG,Togo,6023185,87,en_US,Cote d'Ivoire,CI,Cote d'Ivoire";
NSArray * arrData = [countryStr componentsSeparatedByString:#","];;//[countryStr componentsSeparatedByString:#"en_US"];
for(int i=0;i<arrData.count;i++)
{
NSString * str = [arrData objectAtIndex:i];
if ([str isEqualToString:#"en_US"] && i<arrData.count-1)
{
NSString* countryName = [arrData objectAtIndex:i+1];
NSLog(#"countryName %#", countryName);
}
}
But you should manage data in your file, loading from resource.
Best way to do it is
NSString *string = [NSString stringWithFormat: #"%#, %#, %#", var1, var2, var3];
Excuse the formatting/syntax errors. Typing this via iPhone. But if there is any errors, look up stringWithFormat: in iOS documents on the apple developer page for corrections.
Your string seems to have the following pattern:
A number,
An other number,
The country language code,
The name,
A short code,
An (other) name.
So what you can do is to use a loop like this:
for (int i = 0; i < dfd.count; i += 6) {
if ( dfd[i + 2] ) } // check the country code at index i + 2
// Do something
}
}

Too many arguments on string creation

I Downloaded a JSON file and then I try to create a string with one of the values of the downloaded dictionary.
The code I'm using:
NSMutableDictionary *tempDict = [listaShowsFiltrada objectAtIndex:indexPath.row];
NSLog(#"%#", tempDict);
cell.labelLugar.text = [tempDict objectForKey:#"local"]; //This is working
NSString *stringCidadeEstado = [[NSString alloc] initWithString:#"%# - %#", [[tempDict objectForKey:#"cidade"] stringValue], [[tempDict objectForKey:#"estado"] stringValue]]; //This is not working
The NSLog:
2014-04-27 11:57:46.645 {
cidade = "S\U00e3o Paulo";
"cod_agenda" = 15;
data = "05/05/2014";
estado = SP;
"hora_show" = "22:00";
local = "Teatro Renaissance";
}
2014-04-27 11:57:46.655 {
cidade = "Belo Horizonte";
"cod_agenda" = 16;
data = "06/06/2014";
estado = MG;
"hora_show" = "22:00";
local = "Teatro Sesi Minas";
}
2014-04-27 11:57:46.656 {
cidade = Curitiba;
"cod_agenda" = 14;
data = "14/06/2014";
estado = PR;
"hora_show" = "22:00";
local = "Teatro Regi Vogue";
}
The JSON file:
[{"cod_agenda":"15","local":"Teatro Renaissance","cidade":"S\u00e3o Paulo","estado":"SP","data":"05\/05\/2014","hora_show":"22:00"},{"cod_agenda":"16","local":"Teatro Sesi Minas","cidade":"Belo Horizonte","estado":"MG","data":"06\/06\/2014","hora_show":"22:00"},{"cod_agenda":"14","local":"Teatro Regi Vogue","cidade":"Curitiba","estado":"PR","data":"14\/06\/2014","hora_show":"22:00"}]
The error:
Too many arguments to method call, expected 1, have 3.
The method initWithString takes only one argument, you want to use initWithFormat:
NSString *stringCidadeEstado = [[NSString alloc] initWithFormat:#"%# - %#", [[tempDict objectForKey:#"cidade"] stringValue], [[tempDict objectForKey:#"estado"] stringValue]];

How to get mail configuration information if allowed?

Hi I am using SMTP server framework to send mails.
NSArray *arr1 = [testMsg.fromEmail componentsSeparatedByString:#"#"];
NSArray *arr2 = [[arr1 objectAtIndex:1] componentsSeparatedByString:#"."];
if ([arr2 containsObject:#"gmail"]) {
testMsg.relayHost = #"smtp.gmail.com";
}
else if ([arr2 containsObject:#"yahoo"]) {
testMsg.relayHost = #"smtp.mail.yahoo.com";
}
else if ([arr2 containsObject:#"hotmail"] || [arr2 containsObject:#"live"]) {
testMsg.relayHost = #"smtp.live.com";
}
else
{
NSString *smtpRelay = [[NSString alloc]init];
smtpRelay = [NSString stringWithFormat:#"smtp.%#.com",[arr2 objectAtIndex:0]];
testMsg.relayHost = smtpRelay;
}
testMsg.requiresAuth = YES;
testMsg.login = #"mycompanyUserName#mycompany.com";
testMsg.password = #"********";
testMsg.subject = #"This is the email subject line";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
If i want to send a mail from my office ID or other i want to fetch mail info automatically that is configured in MAIL application.
So That i can send a mail from configured mail (in device).is it possible to get the info like this ...if allowed ....please help me ......I don't want to user to enter id and password...Thanks in advance

iOS clickable text inside UITextView

Is there a way to make clickable parts of UITextView. Actually I want to make text something like
By clicking “Register” above, you are agreeing to the Terms of Services and Privacy Statement
where Terms of Services should be one link and Privacy Statement another. And by clicking on those I should do something.
I did it with the code above using this project
- (void)_configureTermsLabel
{
self.termsOfUseLabel.hidden = YES;
self.termsAndConditionsLabel = [[TTTAttributedLabel alloc] initWithFrame:self.termsOfUseLabel.frame];
self.termsAndConditionsLabel.font = [UIFont systemFontOfSize:14];
self.termsAndConditionsLabel.lineBreakMode = UILineBreakModeWordWrap;
self.termsAndConditionsLabel.numberOfLines = 0;
NSString *termsStr = NSLocalizedString(#"Terms of use", #"Terms of use");
NSString *privacyStr = NSLocalizedString(#"Privacy Policy", #"Privacy Policy");
NSString *andStr = NSLocalizedString(#"and", #"and");
NSString *conductStr = NSLocalizedString(#"Code of conduct", #"Code of conduct");
NSString *termsAndConditionsStr = [NSString stringWithFormat:#"%# - %# %# %#", termsStr,
privacyStr, andStr, conductStr];
self.termsAndConditionsLabel.text = termsAndConditionsStr;
NSString *languageCode = [[GLQAppDelegate sharedDelegate] languageIdentifier];
NSURL *termsURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQTermsOfUseURL, languageCode]];
NSURL *privacyURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQPrivacyPolicyURL, languageCode]];
NSURL *conductURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQCodeOfConductURL, languageCode]];
NSRange termsRange = [self.termsAndConditionsLabel.text rangeOfString:termsStr];
NSRange privacyRange = [self.termsAndConditionsLabel.text rangeOfString:privacyStr];
NSRange conductRange = [self.termsAndConditionsLabel.text rangeOfString:conductStr];
[self.termsAndConditionsLabel addLinkToURL:termsURL withRange:termsRange];
[self.termsAndConditionsLabel addLinkToURL:privacyURL withRange:privacyRange];
[self.termsAndConditionsLabel addLinkToURL:conductURL withRange:conductRange];
self.termsAndConditionsLabel.delegate = self;
self.termsAndConditionsLabel.userInteractionEnabled = YES;
[self.scrollView addSubview:self.termsAndConditionsLabel];
}

Resources