我正在尝试将Payumoney集成到Android中,但总是会出现错误
发生了一些错误
以下是代码。
hashcal:
public static String hashCal(String hashString) {
StringBuilder hash = new StringBuilder();
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("SHA-512");
messageDigest.update(hashString.getBytes());
byte[] mdbytes = messageDigest.digest();
for (byte hashByte : mdbytes) {
hash.append(Integer.toString((hashByte & 0xff) + 0x100, 16).substring(1));
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return hash.toString();
}
主要代码:
Random rand = new Random();
String randomString = Integer.toString(rand.nextInt()) + (System.currentTimeMillis() / 1000L);
String txnId = hashCal(randomString).substring(0, 20);
int amount = new BigDecimal(100).setScale(0, RoundingMode.UP).intValue();
String hashSequence = "mLeqrgMpR|"+txnId+"|"+amount+"|Coupons|abcdef|test@gmail.com|udf1|udf2|udf3|udf4|udf5|3d7vtDalxm";
String hash = hashCal(hashSequence);
PayUmoneySdkInitializer.PaymentParam.Builder builder = new
PayUmoneySdkInitializer.PaymentParam.Builder();
builder.setAmount(amount) // Payment amount
.setTxnId(txnId) // Transaction ID
.setPhone("+911234567890") // User Phone number
.setProductName("Coupons") // Product Name or description
.setFirstName("abcdef") // User First name
.setEmail("test@gmail.com") // User Email ID
.setsUrl("https://test.payumoney.com/mobileapp/payumoney/success.php") // Success URL (surl)
.setfUrl("https://test.payumoney.com/mobileapp/payumoney/failure.php")
.setIsDebug(true) // Integration environment - true (Debug)/ false(Production)
.setKey("mLeqrgMpR") // Merchant key
.setMerchantId("12359971"); // Merchant ID
PayUmoneySdkInitializer.PaymentParam paymentParam = builder.build();
//set the hash
paymentParam.setMerchantHash(hash);
PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam, getActivity(), R.style.AppTheme_NoActionBar,false);
每当我尝试执行上面的代码时,payumoney的活动就会完成并抛出吐司“发生了一些错误”。
我做错了什么?
感谢。