2017-02-22 65 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) –