3

我已经集成了 payumoney 支付通道。但我在 webView 中收到错误,未加载此https://test.payu.in/_payment测试网址。

在此处输入图像描述

我的代码:

 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];

我已参考此链接PayUMoney 支付网关问题。我已正确传递所有参数。我不明白我错了什么。

我通过以下路径获得了我的商人和盐密钥

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

3 回答 3

0

对于测试代码,请使用以下键:

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

还有你的网址

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

注意:对于实时使用,请将 KEY 和 SALT 值替换为您自己的值。& 设置网址

[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@" https://secure.payu.in/_payment"]]];
于 2015-07-29T09:14:03.383 回答
0

我在上面找到了我的问题解决方案。我没有在forHTTPHeaderField字段值中传递“charset=utf-8”。

在 url 请求中传递这种方式参数。

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

没有“charset=utf-8”的旧版本可以正常工作,但最新代码在 url 中添加了“charset=utf-8”。

于 2015-08-13T16:55:55.273 回答
0

NSString *serviceprovider = @"";

将服务提供者字段留空。那应该行得通。

于 2015-08-12T17:00:13.877 回答