2017-02-22 62 views
1

我FreeCharge的钱包集成在工作中的机器人。我们也购买了商家ID和集成密钥。FreeCharge的钱包集成在Android的

我跟着FreeCharge的指南中给出的指令,但我还是坚持了一条错误消息,在我的日志为“无效校验/校验和不匹配”

目前我正在等待FreeCharge的客户服务中心回复错误

请帮助我通过这个问题来得到,如果集成任何你这个FreeCharge的钱包整合。

我cameup的代码的截图和错误日志

代码

Code

代码继续... Code Continue...

错误日志

Error Log

+0

有你解决这个问题? –

回答

-1

您好我得到了同样的问题。

产生通过这个代码校验。

private void generateChecksum(String merchantKey) { 


    JSONObject jsonObject = new JSONObject(); 


    checksumObj = new ChecksumObj(mEdtAmount.getText().toString(), "ANDROID", mEdtEmail.getText().toString(), 
      "https://www.google.com", "merchantID", getTransactionID(), mEdtMobile.getText().toString(), "auth", "https://www.google.com"); 


    try { 
     jsonObject.put("amount", checksumObj.getAmount()); 
     jsonObject.put("channel", checksumObj.getChannel()); 
     jsonObject.put("email", checksumObj.getEmail()); 
     jsonObject.put("furl", checksumObj.getFurl()); 
     jsonObject.put("merchantId", checksumObj.getMerchantId()); 
     jsonObject.put("merchantTxnId", checksumObj.getMerchantTxnId()); 
     jsonObject.put("mobile", checksumObj.getMobile()); 
     jsonObject.put("productInfo", checksumObj.getProductInfo()); 
     jsonObject.put("surl", checksumObj.getSurl()); 

    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 

    String plainText = jsonObject.toString().concat(merchantKey).replace("\\/", "/"); 

    MessageDigest md = null; 

    try { 
     md = MessageDigest.getInstance("SHA-256"); 
    } catch (NoSuchAlgorithmException e) { 
     e.printStackTrace(); 
    } 
    md.update(plainText.getBytes(Charset.defaultCharset())); 
    byte[] mdbytes = md.digest(); 

    // convert the byte to hex format method 1 

    StringBuffer checksum = new StringBuffer(); 
    for (int i = 0; i < mdbytes.length; i++) { 
     checksum.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1)); 
    } 

    jsonCheckSum = checksum.toString(); 

    requestMap(); 



} 

CheckSumObj它实现了Serializable。

public class ChecksumObj implements Serializable { 
String amount, channel, customerName, email, furl, merchantId, merchantTxnId, mobile, productInfo, surl; 

public ChecksumObj(String amount, String channel, String email, String furl, String merchantId, String merchantTxnId, String mobile, String productInfo, String surl) { 
    this.amount = amount; 
    this.channel = channel; 
    this.email = email; 
    this.furl = furl; 
    this.merchantId = merchantId; 
    this.merchantTxnId = merchantTxnId; 
    this.mobile = mobile; 
    this.productInfo = productInfo; 
    this.surl = surl; 
} 


public String getAmount() { 
    return amount; 
} 

public void setAmount(String amount) { 
    this.amount = amount; 
} 

public String getChannel() { 
    return channel; 
} 

public void setChannel(String channel) { 
    this.channel = channel; 
} 

public String getCustomerName() { 
    return customerName; 
} 

public void setCustomerName(String customerName) { 
    this.customerName = customerName; 
} 

public String getEmail() { 
    return email; 
} 

public void setEmail(String email) { 
    this.email = email; 
} 

public String getFurl() { 
    return furl; 
} 

public void setFurl(String furl) { 
    this.furl = furl; 
} 

public String getMerchantId() { 
    return merchantId; 
} 

public void setMerchantId(String merchantId) { 
    this.merchantId = merchantId; 
} 

public String getMerchantTxnId() { 
    return merchantTxnId; 
} 

public void setMerchantTxnId(String merchantTxnId) { 
    this.merchantTxnId = merchantTxnId; 
} 

public String getMobile() { 
    return mobile; 
} 

public void setMobile(String mobile) { 
    this.mobile = mobile; 
} 

public String getProductInfo() { 
    return productInfo; 
} 

public void setProductInfo(String productInfo) { 
    this.productInfo = productInfo; 
} 

public String getSurl() { 
    return surl; 
} 

public void setSurl(String surl) { 
    this.surl = surl; 
}} 

请求的HashMap。

private void requestMap() { 
    checkoutRequestMap = new HashMap<>(); 
    checkoutRequestMap.put("amount", checksumObj.getAmount()); 
    checkoutRequestMap.put("channel", "ANDROID"); 
    checkoutRequestMap.put("email", checksumObj.getEmail()); 
    checkoutRequestMap.put("furl", "https://www.google.com"); 
    checkoutRequestMap.put("merchantId", "MerchantID"); 
    checkoutRequestMap.put("merchantTxnId", checksumObj.getMerchantTxnId()); 
    checkoutRequestMap.put("mobile", checksumObj.getMobile()); 
    checkoutRequestMap.put("productInfo", "auth"); 
    checkoutRequestMap.put("surl", "https://www.google.com"); 
    checkoutRequestMap.put("checksum", jsonCheckSum); 

    FreeChargePaymentSdk.startSafePayment(FreeChargeMainActivity.this, checkoutRequestMap, freeChargePaymentCallback); 

} 

TransactionID random。

private String getTransactionID() { 

    SecureRandom random = new SecureRandom(); 

    return new BigInteger(48, random).toString(16) + mEdtMobile.getText().toString().substring(0, 5); 

} 

FreeCharge的回调。

FreeChargePaymentCallback freeChargePaymentCallback = new FreeChargePaymentCallback() { 

    @Override 
    public void onTransactionFailed(HashMap<String, String> txnFailResponse) { 
     Toast.makeText(FreeChargeMainActivity.this, txnFailResponse.get("errorMessage"), Toast.LENGTH_SHORT).show(); 
    } 

    @Override 
    public void onTransactionCancelled() { 
     Toast.makeText(FreeChargeMainActivity.this, "user cancelled the transaction", Toast.LENGTH_SHORT).show(); 
    } 

    @Override 
    public void onTransactionSucceeded(HashMap<String, String> txnSuccessResponse) { 
     Toast.makeText(FreeChargeMainActivity.this, txnSuccessResponse.get("status"), Toast.LENGTH_SHORT).show(); 
     mEdtMobile.setText(""); 
     mEdtAmount.setText(""); 
     mEdtEmail.setText(""); 
     clearFreeChargeCache(); 
    } 

    @Override 
    public void onErrorOccurred(FreechargeSdkException sdkError) { 
     Toast.makeText(FreeChargeMainActivity.this, sdkError.getErrorMessage(), Toast.LENGTH_SHORT).show(); 
    } 
}; 

的build.gradle(项目级)

allprojects { 
repositories { 
    jcenter() 
    maven { 
     url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/" 
    } 
}} 

的build.gradle(应用级)

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'in.freecharge.checkout.android:freecharge-checkout-android-sdk:[email protected]' 
compile 'in.juspay:godel:0.6.12.1423' 
testCompile 'junit:junit:4.12'} 

希望这help.Happy编码。

+0

它们都属于同一类吗? –

+0

你可以帮我提供Freecharge集成的任何参考资料吗?如何做任务。 –

+0

@Crime_Master_Go看到这个[链接](https://bitbucket.org/freecharge/paywithfreecharge-android) –