Closed mastahnish closed 8 years ago
There's quite a bit going on in those logs.. :) Are you trying to swipe the card first and then you insert it? Also, did you modify the code to do an Authorization instead of a Sale transaction? I just successfully used the sample app yesterday so I'd need the exact steps you are going through, as well as modifications, to understand better what's happening. The error itself is due to a null invoice ID, but why that's happening is what we need to figure out.
@ppmtscory I tried both scenarios
You have to know that I want to utilize accessToken provide from my customer's API. So on the customer's server side there's a curl command done and I will be provided with accessToken that I will use in authentications. Regarding the code - yes, I slightly modified it. Here's what I changed:|
LoginActivity.java
I changed this line: String token = LocalPreferences.getLiveMidtierToken(LoginActivity.this);
to assign the token that I get from customer's API
String token = "A015******************************************c";
(47 characters)
PayPalHereSDKWrapper.java
I modified setAccessTOkenToSDK
method:from
public void setAccessTokenToSDK(String compositeAccessToken, final PayPalHereSDKWrapperCallbacks listener){
PayPalHereSDK.setCredentialsFromCompositeStrFromMidTierServer(compositeAccessToken, new DefaultResponseHandler<Merchant, PPError<MerchantManager.MerchantErrors>>() {
@Override
public void onSuccess(Merchant merchant) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onSuccess");
if (null != listener) {
listener.onSuccessfulCompletionOfSettingAccessTokenToSDK();
}
}
@Override
public void onError(PPError<MerchantManager.MerchantErrors> merchantErrorsPPError) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onError error: " + merchantErrorsPPError);
if (null != listener) {
listener.onErrorWhileSettingAccessTokenToSDK();
}
}
});
}
to
public void setAccessTokenToSDK(String accessToken, final PayPalHereSDKWrapperCallbacks listener){
Credentials credentials = new OAuthCredentials(accessToken);
PayPalHereSDK.setCredentials(credentials, new DefaultResponseHandler<Merchant, PPError<MerchantManager.MerchantErrors>>() {
@Override
public void onSuccess(Merchant merchant) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onSuccess");
if (null != listener) {
listener.onSuccessfulCompletionOfSettingAccessTokenToSDK();
}
}
@Override
public void onError(PPError<MerchantManager.MerchantErrors> merchantErrorsPPError) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onError error: " + merchantErrorsPPError);
if (null != listener) {
listener.onErrorWhileSettingAccessTokenToSDK();
}
}
});
}
And then I proceeded with CardReader connection and payment.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! One more unexpected thing: New error happens today when initializing SDK in that way (yesterday it was initializing SDK correctly) ! I'm getting error like this:
06-10 09:58:49.839 21817-21817/com.paypal.heresdk.sampleapp E/RiskComponent: LoadConfigurationRequest failed.
06-10 09:58:49.839 21817-21817/com.paypal.heresdk.sampleapp E/RiskComponent: BeaconRequest failed.
06-10 09:58:50.349 21817-21817/com.paypal.heresdk.sampleapp E/PPHSDK: MerchantStatusRequest- RESPONSE BODY ON ERROR: java.net.UnknownHostException: Unable to resolve host "www.paypal.com": No address associated with hostname
06-10 09:58:50.349 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: PPHSDK.MerchantManagerImpl-No active merchant. Returning null.
06-10 09:58:50.349 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: CalLoggingService-NEW MESSAGE: {"data":{"timestamp":"2016-06-10 08:58:50:357 +0000","result":"-1","level":"ERROR","actionId":"Message","details":": RESPONSE BODY ON ERROR: java.net.UnknownHostException: Unable to resolve host \"www.paypal.com\": No address associated with hostname","sessionId":"570d1a66-7c4b-4f3a-acd0-0cc2ad0ede29"},"type":"BIZ","status":"-1","name":"Message.CLIENT"}
06-10 09:58:50.359 21817-21817/com.paypal.heresdk.sampleapp E/PPHSDK: MerchantStatusRequest-Failure response from backend and contains errors. Error detailscode=01031;type=null;message=We were unable to process the Http Request;details=null
06-10 09:58:50.359 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: PPHSDK.MerchantManagerImpl-No active merchant. Returning null.
06-10 09:58:50.369 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: CalLoggingService-NEW MESSAGE: {"data":{"timestamp":"2016-06-10 08:58:50:377 +0000","result":"-1","level":"ERROR","actionId":"Message","details":": Failure response from backend and contains errors. Error detailscode=01031;type=null;message=We were unable to process the Http Request;details=null\n","sessionId":"570d1a66-7c4b-4f3a-acd0-0cc2ad0ede29"},"type":"BIZ","status":"-1","name":"Message.CLIENT"}
06-10 09:58:50.379 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: CalLoggingService-NEW MESSAGE: {"data":{"data":"https:\/\/www.paypal.com\/webapps\/hereapi\/merchant\/v1\/status","timestamp":"2016-06-10 08:58:50:395 +0000","result":"-1","level":"INFO","actionId":"MerchantStatusRequest","sessionId":"570d1a66-7c4b-4f3a-acd0-0cc2ad0ede29"},"type":"BIZ","status":"-1","name":"MerchantStatusRequest.CLIENT"}
06-10 09:58:50.420 21817-21817/com.paypal.heresdk.sampleapp D/dalvikvm: GC_FOR_ALLOC freed 398K, 11% free 4259K/4772K, paused 29ms, total 29ms
06-10 09:58:50.430 21817-21817/com.paypal.heresdk.sampleapp D/PPHSDK: CalLoggingService-NEW MESSAGE: {"data":{"data":"null","timestamp":"2016-06-10 08:58:50:443 +0000","result":"-1","duration":40444,"level":"ERROR","actionId":"MerchantStatusRequest","sessionId":"570d1a66-7c4b-4f3a-acd0-0cc2ad0ede29"},"type":"BIZ","status":"-1.1031","name":"MerchantStatusRequest.CLIENT"}
06-10 09:58:50.450 21817-21817/com.paypal.heresdk.sampleapp D/PayPalHereSDKWrapper: initializeSDK setCredentialsFromDoddlesAPIAccessToken onError error: com.paypal.merchant.sdk.domain.PPError@41fb6130
06-10 09:58:50.450 21817-21817/com.paypal.heresdk.sampleapp D/LoginActivity: PayPalHere SDK initialize onErrorWhileSettingAccessTokenToSDK. Token: A015db356l3s-xIC4iLQP3jqzpn9wpDvYPeoB4VYgCh5YII
06-10 09:58:50.550 21817-21817/com.paypal.heresdk.sampleapp D/Volley: [1] Request.finish: 40592 ms: [ ] https://www.paypal.com/webapps/hereapi/merchant/v1/status 0x2972d4bd NORMAL 2
UPDATE: New error is not showing anymore.
UPDATE: We tried to run Sample App and initialize SDK using mid-tier server (by entering credentials in WebView) and it worked. So knowing that I suppose that using
PayPalHereSDK.setCredentials(..)
method instead of PayPalHereSDK.setCredentialsFromCompositeStrFromMidTierServer(...)
method is the root cause.
Please take a look and let me know how to use PayPalHereSDK.setCredentials(..)
method in a proper way.
Ah, thank you for the clarification. Yes, the sample app is indeed set up to utilize the composite token that's provided from the retail node mid-tier server. Since it's set up that way, and is used just as a demo, you should be able to modify it to use just the credentials, however it's possible that there's someplace that's not getting changed. Therefore, it tries to read the information from a token that doesn't exist. Either way, the sample app should just be used as a reference of how the flow of operations should be handled. In your own integration, you can definitely use just setCredentials()
with the access token directly. An example of that is in the readme of the repo.
Also, if you wanted to utilize the same mid-tier server and composite token setup for your own integration, that server is found here and can be deployed directly to Heroku if you're using that for a cloud server.
@ppmtscory the problem is that I modified sample app to use setCredentials()
and I'm getting this NPE error when making transactions. Do you have any idea how to solve it?
It's happening because there's no active merchant set which is due to somewhere expecting the composite token but receiving just the access token directly. Since the sample app isn't set up that way by default, in order to see what needs to be changed, I will need to try to modify it myself to get it going via setCredentials
. This will take some time, but I will update you here once I'm able to do so.
@ppmtscory This will be much appreciated. Please test it in that way and let me know about the possible solutions. Thank you!
Alright, that didn't take as long as I anticipated.. :)
LoginActivity.java
you need to modify the code to use your own access token instead of the one stored in local preferences. Or if you wanted to store your access token in local preferences and grab it from there, then I suppose you could do that as well.setAccessTokenToSDK
, I changed the variable being passed in to accessToken
simply to make it more understandable and that was what was also passed to OAuthCredentials()
. Below is the full setAccessTokenToSDK
function.public void setAccessTokenToSDK(String accessToken, final PayPalHereSDKWrapperCallbacks listener){
Credentials credentials = new OAuthCredentials(accessToken);
PayPalHereSDK.setCredentials(credentials, new DefaultResponseHandler<Merchant, PPError<MerchantManager.MerchantErrors>>() {
@Override
public void onSuccess(Merchant merchant) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onSuccess");
if (null != listener) {
listener.onSuccessfulCompletionOfSettingAccessTokenToSDK();
}
}
@Override
public void onError(PPError<MerchantManager.MerchantErrors> merchantErrorsPPError) {
Log.d(LOG_TAG, "initializeSDK setCredentialsFromCompositeStr onError error: " + merchantErrorsPPError);
if (null != listener) {
listener.onErrorWhileSettingAccessTokenToSDK();
}
}
});
}
With these changes, i was able to successfully initialize the merchant and subsequently process a successful payment.
Thank you @ppmtscory for that for your effort, but please note that this is exactly what I did already (I described it in my previous comments). Despite I did it in that way I got that NPE error. I feel a little confused now what can bee the reason of this NPE on my side...
I understand that, however, with me doing the same and it working, there's likely either something else that was modified in your code or maybe there's an issue with the merchant account you are using.
Can you email with subject 'Attn: Cory' so that we can communicate about account specific things outside of this public forum?
@ppmtscory Sure, just sent you an email.
Hello,
i'm using Sample app (version 1.6.2.6) and tried to perform test transaction (using Live environment)
However, when I was asked to insert a card into CardReader it started transaction and crashed. This is what I found in logs: