【问题标题】:iOS PayUMoney SDK-key is not validiOS PayUMoney SDK 密钥无效
【发布时间】:2017-03-06 08:42:16
【问题描述】:

我已集成 payumey 支付网关。而且我能够使用密钥创建正确的哈希,但最后我收到一条警告消息,因为“密钥无效”。会有什么问题?

这里是代码。我使用链接“https://www.payumoney.com/payment-gateway-integration-guide.html”下载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;
}

【问题讨论】:

  • 这两个地方你传了什么keyself.params.key = @"mykeyvalue"; self.params.merchantid = @"merchantid";
  • 我从服务器团队获得的数据,例如:self.params.key@"mdyCKV"; self.params.merchantid=@"4914106"; [虚拟值]
  • @Abhishek Biswas 你解决了这个问题吗?请尽快回复。

标签: ios objective-c transactions payumoney


【解决方案1】:

请在您发送 payumoney 以创建哈希键时检查数据,并使用服务器 api 数据创建您的哈希键。

【讨论】:

    【解决方案2】:
    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-02
      • 2016-11-08
      相关资源
      最近更新 更多