Payumoney getway error occur in ios

旧城冷巷雨未停 提交于 2019-12-10 19:22:20

问题


I have integrate payumoney payment getway. But i get error in webView not load this https://test.payu.in/_payment testing url.

And my code:

 int i = arc4random() % 9999999999;
    NSString *strHash = [self createSHA512:[NSString stringWithFormat:@"%d%@",i,[NSDate date]]];
    NSString *txnid1 = [strHash substringToIndex:20];
    NSLog(@"tnx1 id %@",txnid1);

    NSString *key = @"xxxxx"; // my key
    NSString* salt = @"xxxxxx"; // my salt key

    NSString *amount = @"1.00";
    NSString *productInfo = @"Nice product";
    NSString *firstname = @"Mani";
    NSString *email = @"mani.ingenius@gmail.com";
    NSString *phone = @"1234566";
    NSString *surl = @"http://www.google.com/";
    NSString *furl = @"http://www.github.in/";
    NSString *serviceprovider = @"payu_paisa";

    NSString *hashValue = [NSString stringWithFormat:@"%@|%@|%@|%@|%@|%@|||||||||||%@",key,txnid1,amount,productInfo,firstname,email,salt];


    NSString *hash = [self createSHA512:hashValue];
    NSDictionary *parameters = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:txnid1,key,amount,productInfo,firstname,email,phone,surl,furl,hash,serviceprovider
                                                                    , nil] forKeys:[NSArray arrayWithObjects:@"txnid",@"key",@"amount",@"productinfo",@"firstname",@"email",@"phone",@"surl",@"furl",@"hash",@"service_provider", nil]];


    __block NSString *post = @"";
    [parameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        if ([post isEqualToString:@""]) {
            post = [NSString stringWithFormat:@"%@=%@",key,obj];
        }else{
            post = [NSString stringWithFormat:@"%@&%@=%@",post,key,obj];
        }

    }];

    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://test.payu.in/_payment"]]];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
    [request setHTTPBody:postData];

    [web_view_PayU loadRequest:request];

i have refer this link PayUMoney payment gateway issue .And I have pass all parameter correct. I have not understand what i am wrong.

I get my merchant and salt key this following path

 Seller Dashboard -> Settings -> My account -> Merchant Key - Salt

回答1:


For Test code use these keys:

NSString *key = @"JBZaLc";
NSString* salt = @"GQs7yium";

And ur Url

[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://test.payu.in/_payment"]]];

NOTE: For live Use,replace KEY and SALT value with your own value. & setURL with

[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@" https://secure.payu.in/_payment"]]];



回答2:


NSString *serviceprovider = @"";

Leave the Service Provider field as blank. That should work.




回答3:


I found above my question solution. I have not pass "charset=utf-8" in forHTTPHeaderField field value.

pass this way parameter in url request.

[request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Current-Type"];

old version without "charset=utf-8" work correct but latest code add "charset=utf-8" in url.



来源:https://stackoverflow.com/questions/31681781/payumoney-getway-error-occur-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!