PayUMoney支付网关问题

我必须在我的iOS应用程序中集成PayUMoney支付网关。 他们没有适用于iOS的SDK。 所以我必须在webview中加载一些url来付款。 我的参数是

int i = arc4random() % 9999999999; NSString *strHash = [self createSHA512:[NSString stringWithFormat:@"%d%@",i,[NSDate date]]];// Generatehash512(rnd.ToString() + DateTime.Now); NSString *txnid1 = [strHash substringToIndex:20]; NSLog(@"tnx1 id %@",txnid1); NSString *key = @"JBZaLc"; NSString *amount = @"1000"; NSString *productInfo = @"Nice product"; NSString *firstname = @"Mani"; NSString *email = @"mani.ingenius@gmail.com"; NSString *phone = @"1234566"; NSString *surl = @"www.google.com"; NSString *furl = @"www.google.com"; NSString *serviceprovider = @"payu_paisa"; NSString *action = @"https://test.payu.in/_payment"; NSString *hashValue = [NSString stringWithFormat:@"%@|%@|%@|%@|%@|%@|udf1|udf2|udf3|udf4|udf5||||||salt",key,txnid1,amount,productInfo,firstname,email]; NSString *hash = [self createSHA512:hashValue]; NSDictionary *parameters = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:txnid1,key,amount,productInfo,firstname,email,phone,surl,furl,hash,serviceprovider,action, nil] forKeys:[NSArray arrayWithObjects:@"txnid",@"key",@"amount",@"productinfo",@"firstname",@"email",@"phone",@"surl",@"furl",@"hash",@"service_provider",@"action", nil]]; 

我必须使用POST方法和我的testingURL( https://test.payu.in/_payment ),并且需要传递参数。 我有字典中的所有参数(“参数”)中的键和值。 所以我试着下面的代码

  NSData *dataValue = [self getPropertiesAsData:parameters]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://test.payu.in/_payment"]]; // Create a mutable copy of the immutable request and add more headers NSMutableURLRequest *mutableRequest = [request mutableCopy]; [mutableRequest setHTTPMethod: @"POST"]; [mutableRequest setHTTPBody: dataValue]; request = [mutableRequest copy]; [_webviewSample loadRequest:request]; -(NSData *)getPropertiesAsData :(NSDictionary *)dict{ NSMutableData *body = [NSMutableData postData]; [dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [body addValue:[obj stringByReplacingOccurrencesOfString:@" " withString:@"%20"] forKey:key]; }]; return body; } -(NSString *)createSHA512:(NSString *)string { const char *cstr = [string cStringUsingEncoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithBytes:cstr length:string.length]; uint8_t digest[CC_SHA512_DIGEST_LENGTH]; CC_SHA512(data.bytes, data.length, digest); NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA512_DIGEST_LENGTH * 2]; for(int i = 0; i < CC_SHA512_DIGEST_LENGTH; i++) [output appendFormat:@"%02x", digest[i]]; return output; } 

但是当我运行这个时,它说“强制参数tnxid丢失”。 但是我已经通过了参数字典中可以看到的tnxid。 如果我正确地通过一切,那么结果将是网页,用户可以select银行的详细信息等,我必须加载它在我的networking视图。

请帮我find我做错了什么,或者我应该怎么做才能得到正确的结果。

我find答案成功。 我的工作代码列在下面

 int i = arc4random() % 9999999999; NSString *strHash = [self createSHA512:[NSString stringWithFormat:@"%d%@",i,[NSDate date]]];// Generatehash512(rnd.ToString() + DateTime.Now); NSString *txnid1 = [strHash substringToIndex:20]; NSLog(@"tnx1 id %@",txnid1); NSString *key = @"JBZaLc"; NSString *amount = @"1000"; NSString *productInfo = @"Nice product"; NSString *firstname = @"Mani"; NSString *email = @"mani.ingenius@gmail.com"; NSString *phone = @"1234566"; NSString *surl = @"www.google.com"; NSString *furl = @"www.google.com"; NSString *serviceprovider = @"payu_paisa"; NSString *hashValue = [NSString stringWithFormat:@"%@|%@|%@|%@|%@|%@

||GQs7yium",key,txnid1,amount,productInfo,firstname,email]; 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"%5D%5D%5D; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"]; [request setHTTPBody:postData]; [_webviewSample loadRequest:request];

然后function被使用

 -(NSString *)createSHA512:(NSString *)string { const char *cstr = [string cStringUsingEncoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithBytes:cstr length:string.length]; uint8_t digest[CC_SHA512_DIGEST_LENGTH]; CC_SHA512(data.bytes, (CC_LONG)data.length, digest); NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA512_DIGEST_LENGTH * 2]; for(int i = 0; i < CC_SHA512_DIGEST_LENGTH; i++) [output appendFormat:@"%02x", digest[i]]; return output; } 

最后我解决了关于PayU印度不支付U,payU和payUindia有一点区别,如提到 )整合(上面的代码是payU钱帮助很多)的问题下载github在这里回购

您只需要删除一个额外的参数,即service_provider,其值为payu_paisa。

 int i = arc4random() % 9999999999; NSString *strHash = [self createSHA512:[NSString stringWithFormat:@"%d%@",i,[NSDate date]]];// Generatehash512(rnd.ToString() + DateTime.Now); NSString *txnid1 = [strHash substringToIndex:20]; NSLog(@"tnx1 id %@",txnid1); NSString *key = @"YOURKEY"; NSString *salt = @"YOURSALTKEY"; NSString *amount = @"100"; NSString *productInfo = @"Niceproduct"; NSString *firstname = @"Deepak"; NSString *email = @"iphonemaclover@gmail.com"; NSString *phone = @"9212138007"; NSString *surl = @"www.google.com"; NSString *furl = @"www.google.com"; 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 , nil] forKeys:[NSArray arrayWithObjects:@"txnid",@"key",@"amount",@"productinfo",@"firstname",@"email",@"phone",@"surl",@"furl",@"hash", 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"%5D%5D%5D; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"]; [request setHTTPBody:postData]; [_webviewSample loadRequest:request];

编辑:如何处理URL付款是否成功

 -(void)webViewDidFinishLoad:(UIWebView *)webView{ if (web_view_PayU.isLoading) return; NSURL *requestURL = [[web_view_PayU request] URL]; NSLog(@"requestURL=%@",requestURL); NSString *getStringFromUrl=[NSString stringWithFormat:@"%@",requestURL]; if ([getStringFromUrl isEqualToString:@"https://test.payu.in/yoursucessurladdedhere "]||[getStringFromUrl isEqualToString:@"https://secure.payu.in/yoursucessurladdedhere "]) { //SUCCESS ALERT //jump to place order API } else if ([getStringFromUrl isEqualToString:@"https://test.payu.in/yourfailureurladdedhere "]||[getStringFromUrl isEqualToString:@"https://secure.payu.in/yourfailureurladdedhere"]) { // FAIL ALERT UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Sorry!" message:@"Your Order Not Successfull!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; alert.tag=2222; [alert show]; } } 

对于Payout U的Android集成检查链接 –

我邮寄到Payumoney技术团队,并得到我的答案,为什么我得到错误“对不起,发生了一些问题”。

对技术团队得到了一个快速回复:

 Recently, we have done some modifications in test environment due to which test key-JBZaLc and salt-GQs7yium will not work anymore. In order to test the gateway using a test key and salt, kindly follow these steps: 1 - Go on https://test.payumoney.com 2 - Sign up as a merchant - use any of your valid email ids - kindly do not use a random email id. 3 - Complete the "Business Details" - you may use PAN no. ABCDE1234F and DOB - 01/04/1990 4 - Complete "Bank Account Details" (You may use IFSC- ALLA0212632) 5 - Go to below mentioned location to get the Test Merchant Id : Seller Dashboard -> Settings -> My account -> Profile Settings Once you provide your test merchant id, we will approve it so that you can find your test key and salt at : Seller Dashboard -> Settings -> My account -> Merchant Key - Salt 

下载Github存储库