首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS PayUMoney SDK-密钥无效

iOS PayUMoney SDK-密钥无效
EN

Stack Overflow用户
提问于 2017-03-06 16:42:17
回答 2查看 830关注 0票数 0

我已经集成了支付网关。我可以用密钥创建正确的散列,但在最后我收到一条警告消息,因为“密钥无效”.what会是问题吗?

下面是代码。我使用"https://www.payumoney.com/payment-gateway-integration-guide.html“链接下载payumoney SDK。

代码语言:javascript
复制
- (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;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-06 17:12:34

当您发送用于创建散列密钥的payumoney和用于创建散列密钥的服务器api数据时,请检查数据。

票数 1
EN

Stack Overflow用户

发布于 2017-04-28 13:06:25

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42621051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档