I'm working with PayPal Adaptive Payments' IPN. I was able to get the IPN to work, but when I decided to get payment details of a COMPLETED transaction back from PayPal, the PaymentDetails class' getReceiverList method returned null.
PaymentDetailsRequest paymentDetailsRequest = new PaymentDetailsRequest("en_US", ServiceEnvironment.SANDBOX);
paymentDetailsRequest.setPayKey(payKey);
PaymentDetailsResponse paymentDetailsResponse = paymentDetailsRequest.execute(credentialObj);
PaymentDetails paymentDetails = paymentDetailsResponse.getPaymentDetails();
List<Receiver> receiverList = paymentDetails.getReceiverList();
// receiverList returns null
That shouldn't be happening because the transaction has completed and there obviously is a receiver.
If I pull other data from the same paymentDetails object such as the payment status, i get the proper result.
String paymentStatus = paymentDetails.getStatus();
// paymentStatus returns COMPLETED
Has anyone come across this and could tell me why this is happening?
Just in case someone comes across this problem, I have found out that the PayPal Adaptive Payments' IPN still has many glitches, this being one of them. Basically the method getReceiverList() does not get anything. This will be the case for every method that returns null when it should be returning something.
Related
I'm detecting if the email is validated with firebase via the instruction shown on the title and it works, but with an strange error.
First time it tries to verify mail even if verified it says it's not verified. When method is again executed it returns it's verified.
I've checked that this is not a time issue, even if I leave a long time from the moment I verify the email to the moment I tell the app to check if it is verified, it always fails on its first attempt.
What could I do so, if the email is verified, it returns that it is verified from the first attempt?
Apparently you are still using the old Firebase IdToken and hence it shows the old state. The same issue occurs when you update user's custom claims but if you still keep using the old idtoken then the custom claims won't reflect.
user.getIdToken(true).addOnSuccessListener(new OnSuccessListener<GetTokenResult>() {
#Override
public void onSuccess(GetTokenResult result) {
String idToken = result.getToken();
//Do whatever
Log.d(TAG, "GetTokenResult result = " + idToken);
}
});
You should pass true in the getIdToken so it'll refresh the token and then check if the email is shown verified in the first go. To make sure whatever I have explained above, you can try logging the idtoken and see if the email was verified on old and new idtoken.
I am trying to make transaction via bitcoinj (version 0.14.3) and i am expecting to get change back after payment. I am working with testnet, it's not real bitcoins.
I have next code:
Transaction tx = new Transaction(this.networkParameters);
Coin coinToSent = Coin.valueOf(Config.APP_COST);
Coin coinToChange = Coin.valueOf(walletBalance.getValue() - coinToSent.getValue());
tx.addOutput(coinToSent, appAddress);
tx.addOutput(coinToChange, changeAddress);
SendRequest request = SendRequest.forTx(tx);
try {
this.walletAppKit.wallet().completeTx(request);
} catch (InsufficientMoneyException e) {
e.printStackTrace();
return false;
}
this.walletAppKit.wallet().commitTx(request.tx);
this.walletAppKit.peerGroup().broadcastTransaction(request.tx);
So, i am putting two outputs into transaction:
Address to sending money
Address of my wallet for getting change back
To the first address i send some money. And to the second address i send next value: all available money on my wallet minus money received to first address.
But after broadcasting i had an unexpected result. After making a few transactions with this scheme, I've noticed wrong values withdrawing from my wallet. What is surprising, sometimes money is withdrawing but sometimes money coming to wallet.
Here is the link to testnet explorer
Can someone explain what i am doing wrong and how to fix it?
The reason that the transaction is not working as expected is that the Bitcoinj Wallet class is doing a lot of things in the background for you - in this case, it is automatically generating a change address where is would store the change for the transaction. The other factor is that bitcoinj calculates a fee that it will give the miners to process the transaction, which is why you're seeing the change address getting less coin that you requested (on the production network it will throw an exception if you don't have enough funds to cover the fee).
I think the best solution here, for cases which are relatively simple, is to work with the Wallet API and let it do the work of generating change address automatically (It's using a deterministic keychain so all the addresses and keys can be regenerated in case you lose the wallet). For example:
public static Transaction send(Wallet wallet,
String destinationAddress,
long satoshis) throws Exception {
Address dest = Address.fromBase58(params, destinationAddress);
SendRequest request = SendRequest.to(dest, Coin.valueOf(satoshis));
SendResult result = wallet.sendCoins(request);
Transaction endTransaction = result.broadcastComplete.get();
return endTransaction;
}
After sendCoins is completed and the transaction is broadcasted, the wallet will maintain the rest (you can save it to a file after the transactin is complete if you really want to make sure you have the keys for the change addresses), here's a way you can see a list of 10 change addresses and their public/private keys :
NetworkParameters params = new MainNetParams();
List<DeterministicKey> keys = wallet.freshKeys(KeyChain.KeyPurpose.CHANGE, 10);
keys.forEach(key -> {
Address address = new Address(params, key.getPubKeyHash());
System.out.println(address +" : " + key.toStringWithPrivate(params));
});
i was trying to call the following web service from my android app, it hung then completed without returning the result:
web service:http://androidexample.com/media/webservice/JsonReturn.php
However when I clicked on the link, it worked fine - the json file displayed. yet it would not work in my app..
but now, it works fine now in my android app, perhaps it was temporarily down is what I am guessing. How can I know if a web service is up and running for an android app to consume ?
Typically, web services are designed to have a status page that can return status text or a HTTP return code to indicate service status.
If it doesn't have that, you can design a function to periodically do a very basic request with a known result to determine state. This is much better than doing a simple ping.
If it was down it would most likely show a HTML error page, which your app would try to parse, which would cause an error.
I had a similar issue, because I needed to know if the user was returning HTML or the correct JSON, to do this I created the ArrayList I was about to use outside of the try/catch of the parse area. You should do the same if you are using a string.
What I mean is, use:
ArrayList<Something> arrayList = new ArrayList<Something>();
String testString = ""; instead of String testString = null;
I was using only ArrayList<Something> arrayList; at one point which is incorrect. If the user then returns HTML, you won't get an error, the user will simply return an empty arraylist or empty string.
You can then plan for that and show some sort of error message. This way you only need one network request but you can still plan for getting the data back, and the server being down.
I'm making a web application for blackberry and I really need the current URL
In the description of documentUrl, it says
This method will return the URL of the currently loaded page of this BrowserField Instance
My code is:
_bf2.requestContent("google.com";);
add(_bf2);
Global.c = _bf2.getDocumentUrl();
Global.be=new BasicEditField("URL: "+Global.c,Global.c);
add(Global.be);
and the weird thing is that www.google.com gets loaded in the BrowserField and the documentUrl returns null.
This is my current code:
BrowserField _bf2 = new BrowserField();
MYBrowserFieldListener _listener = new MYBrowserFieldListener();
_bf2.requestContent("google.com";);
_bf2.addListener(_listener);
String url=_bf2.getDocumentUrl();
Global.be=new BasicEditField("URL: "+url,url);
add(Global.be);
add(_bf2);
I changed it to
final BrowserField _bf2 = new BrowserField();
_bf2.requestContent("google.com";);
//_bf2.addListener(listener);
Global.be=new BasicEditField("URL: "+Global.c,Global.c);
add(Global.be);
add(_bf2);
_bf2.addListener(new BrowserFieldListener(){
public void documentLoaded(BrowserField _bf2, Document document) throws Exception {
Global.c=_bf2.getDocumentUrl();
}
});
But it still returns null. Can someone please tell me how to fix this? Thanks in advance!
I would say that Arhimed has answered your question. An HTTP request is a very time consuming process (from a CPU perspective) and will block until the server responds. I suspect that RIM programmers have coded the requestContent() method as per their own recommendations and are fetching the web content on a separate thread. So, requestContent() will return immediately, when you call getDocumentUrl() it is still null since the fetch thread has probably not even connected to the server at this point.
You will need to implement a BrowserFieldListener and listen for documentLoaded().
I am new to apex and have built an apex schedule class that runs everyday. If an account has an account review date for commissions is two weeks (14 days) away the scheduler will send an email to our Sales Department. The email contains a link to a flow. The flow starts a process to calculate the new commission. To do that, the flow needs to understand to pull information from the account that triggered the email to be sent, the account that has an account review date in 2weeks.
Currently, the email sends out fine with the link to the flow. The link to the flow works, but once you get to the flow, the flow does not know/understand what account it should be pulling information from. I’m not sure if I need to alter my code in my scheduler and/or the code in my flow.
Here is how the flow is accessing information:
Before the first screen, a record lookup in flow occurs. It pulls the information from the account ID and a variable, vaAccountID. I think that the variable {!vaAccountID} is populated with the AccountID that is linked to the commission.
When I run my scheduler, I have it determine if there is an account with an account review date based upon the account Id. It sends the email template with the flow link to the sales department.
The scheduler sends the email and is “happy”. The criteria it needs to execute the method is complete (there is an account with an account review date 14 days from now and it sends the email).
global class AccountReviewSchedulerEmailAcc implements Schedulable {
global void execute (SchedulableContext ctx)
{
sendEmail();
}
public void sendEmail()
{
for(Account acc : [SELECT Id FROM Account WHERE Next_Account_Review_Date__c = : system.Today().addDays(14)])
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId('00XF0000000LfE0');
mail.setTargetObjectId('005J0000000JWYx');
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });
}
}
}
The flow however, is not “happy”. It does not know what account to pull information from.
In the first screen of the flow, it’s supposed to show the recurring revenue and link to the account page. The recurring revenue field is blank. The link to account page does not work.
If I try to advance past the first screen of the flow, I get a generic error screen from Salesforce and a detailed error message from Salesforce. It says:
Encountered unhandled fault when running process Organic_Commission_Determination_Flow/301J000000001Tx exception by user/organization: 00DJ00000000YTl/{4} Source organization: 00DA0000000KZI8 (null)
interaction.dal.exception.DALExecutionFault: ; nested exception is:
common.exception.ApiQueryException:
Account.Annual_RR__c FROM Account WHERE (Account.Id = '{!Commission__c.AccountId__c}')
^ ERROR at Row:1:Column:89 invalid ID field: {!Commission__c.AccountId__c} (There was a problem executing your command.) > RETRIEVE
caused by element : Data lookup.Lookup_Account
caused by: interaction.dal.exception.DALExecutionFault: ; nested exception is:
common.exception.ApiQueryException:
Account.Annual_RR__c FROM Account WHERE (Account.Id = '{!Commission__c.AccountId__c}')
^ ERROR at Row:1:Column:89 invalid ID field: {!Commission__c.AccountId__c} (There was a problem executing your command.) > RETRIEVE
Salesforce Error ID: 580775287-15539 (1733087783)
What does this error message mean? How can I get more information on Salesforce errors and how to trouble shoot on this matter?
I understand this process is very complex but it relates back to one fundamental question: How do I get the flow to realize that it needs to pull information from the account that had the review date 14 days away in my apex scheduler?
Take a look at the SOQL statement that is being executed in the error message:
Account.Annual_RR__c FROM Account WHERE (Account.Id = '{!Commission__c.AccountId__c}')
This is telling me that the link in your email template is passing the literal value "{!Commission__c.AccountId__c}" into your SOQL, rather than binding the value of that field when sending the email out. So rather than passing an Account Id into the URL, you're passing this string which is most certainly not what the flow is expecting.
This can happen when the API name of the field is entered incorrectly in the email template, or if the record bound to the template isn't of type Commission__c as you were expecting. So this could be one of two things: either the record you're sending out isn't of the correct object type for email template 00XF0000000LfE0, or there is no AccountId__c field on the Commission__c object.