PayPal SDK going from payment review page to profilepage - java

In my current Java/Spring project, I am in the phase of integration with PayPal. After configure a Java class to handle the payment process, following the instructions from here, I run my application and try to checkout an order with paypal.
I am redirected correctly to the PayPal login page, and after the login, to this payment review page:
but then after I click on "Continue", instead of finalizing the payment, I am redirected to my profile page.
Here is my code:
Paypal prop = this.paypalDao.get();
String clientId = prop.getClientID();
String clientSecret = prop.getClientSecret();
APIContext apiContext = new APIContext(clientId, clientSecret, "sandbox");
if(payerId != null) {
if(guid != null) {
Payment payment = new Payment();
payment.setId(map.get(guid));
PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.setPayerId(payerId);
payment.execute(apiContext, paymentExecution);
String url = request.getContextPath();
return url+"/orders";
}
} else {
List<Produto> lista_de_produtos = this.getListaDeProdutos(clienteId);
Double total = 0.0;
for(Produto produto : lista_de_produtos)
total = total + produto.getPreco();
DecimalFormat df = new DecimalFormat("0.00");
String svalue = df.format(total).replace(',', '.');
Details details = new Details();
details.setSubtotal(svalue);
Amount amount = new Amount();
amount.setCurrency("BRL");
amount.setTotal(svalue);
amount.setDetails(details);
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setDescription(lista_de_produtos.toString());
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
payment.setTransactions(transactions);
RedirectUrls redirectUrls = new RedirectUrls();
guid = UUID.randomUUID().toString();
String url = request.getContextPath();
redirectUrls.setCancelUrl( url+"/cart" );
redirectUrls.setReturnUrl( url+"/paypal/checkout/"+clientId+"/?guid=" + guid );
payment.setRedirectUrls(redirectUrls);
Payment createdPayment = payment.create(apiContext);
Iterator<Links> links = createdPayment.getLinks().iterator();
while (links.hasNext()) {
Links link = links.next();
if (link.getRel().equalsIgnoreCase("approval_url")) {
map.put("redirectURL", link.getHref());
redirectURL = link.getHref();
}
}
map.put(guid, createdPayment.getId());
payment.setId(map.get(guid));
}
return redirectURL;
Can someone tell me, what am I missing here?

Try printing this value:
System.out.println(url+"/paypal/checkout/"+clientId+"/?guid=" + guid);
The result should be https://www.yoursite.com/paypal/checkout/<number>/?guid=<number>, or a page that would direct there (leaving out https:// to save on bytes could be okay depending on your server configuration).
Additional tests you should try:
Try cancelling on your site.
Try cancelling the payment on paypal's site.
Iff one works but the second does not, then paypal is not redirecting properly, which probably means you're not giving it the right string. Also see comment by #Emile.

Related

zoom sdk for android: can't join as a host

i already inputted all the necessary parameters for it to work according to the docs and the forums but it just can't seem to work on me
private void joinMeeting(Context context, String meetingNumber,String zak, String userName, String usID){
int ret = -1;
MeetingService meetingService = ZoomSDK.getInstance().getMeetingService();
JoinMeetingOptions options = new JoinMeetingOptions();
//JoinMeetingParams params = new JoinMeetingParams();
//params.displayName=userName;
//params.meetingNo =meetingNumber;
//params.password=meetingPassword;
//meetingService.joinMeetingWithParams(context,params,options);
StartMeetingParamsWithoutLogin params = new StartMeetingParamsWithoutLogin();
params.userId = usID; // Based on this id we are able to start the meeting as host
params.userType = MeetingService.USER_TYPE_API_USER;
params.displayName = userName;
params.zoomAccessToken = zak; //getting the zoom access token from start_url
params.meetingNo = meetingNumber; // meetingNo, getting this from create meeting api response
ret = meetingService.startMeetingWithParams(context,params,options);
Log.e("Start Meeting As Host", "===startMeetingWithNumber====ret=" + ret);
}
i tried all generating more meeting using my web sdk but it wont work either

eBay Developer API - GetSellerTransactions

I'm trying to obtain the shipping address of a buyer via the EBay Developers API however I am getting a NullPointerException. I do not understand why since I am sure the buyer has paid for the item and has a shipping address.
This is the code I'm using:
GetSellerTransactionsCall getSellerTransactions = new GetSellerTransactionsCall();
getSellerTransactions.setApiContext(getAPIContext());
Calendar calFrom = new GregorianCalendar();
Date todayFrom = new Date();
calFrom.setTime(todayFrom);
calFrom.add(Calendar.DAY_OF_MONTH, -29);
Calendar calTo = new GregorianCalendar();
Date todayTo = new Date();
calTo.setTime(todayTo);
TimeFilter modifiedTimeFilter = new TimeFilter(calFrom, calTo);
getSellerTransactions.setModifiedTimeFilter(modifiedTimeFilter);
TransactionType[] transactionType = getSellerTransactions.getSellerTransactions();
System.out.println("Size: " + transactionType.length);
// ^^ This returns 2 items as length
UserType userType = transactionType[1].getBuyer();
AddressType shippingAddress = userType.getShippingAddress();
String buyerFirstName = shippingAddress.getFirstName();
// ^^ This line causes a NullPointerException. Same error when I try to get the street address or any other shipping details of buyer. I can get the buyers email just fine using String email = userType.getEmail(); but no shipping details.

Java code to fetch the twitter followers of any user using twitter screen name

I tried to get the twitter followers using the screen name. But i am able to get only my followers screen names where as i am expecting the followers of my followers. But i didn't found any supported method for this.
My code is as follows.
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
AccessToken accessToken = new AccessToken(twitterToken, twitterSecret);
twitter.setOAuthAccessToken(accessToken);
String twitterScreenName = twitter.getScreenName();
IDs followerIDs = twitter.getFollowersIDs(twitterScreenName, -1);
long[] ids = followerIDs.getIDs();
for (long id : ids) {
twitter4j.User user = twitter.showUser(id);
//here i am trying to fetch the followers of each id
System.out.println("Name: " + user.getScreenName());
System.out.println("Location:" + user.getLocation());
}
Can anyone please help me in this.
You will need to do the nesting over here. You are just getting the list of current users followers. But you need to get the list of followers of your followers.
Sample code is as below:
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
String twitterScreenName;
try {
twitterScreenName = twitter.getScreenName();
IDs followerIDs = twitter.getFollowersIDs(twitterScreenName, -1);
long[] ids = followerIDs.getIDs();
for (long id : ids) {
twitter4j.User user = twitter.showUser(id);
//here i am trying to fetch the followers of each id
String userScreenName = user.getScreenName();
System.out.println("Name: " + user.getScreenName());
System.out.println("Location:" + user.getLocation());
IDs followerIDsOfFollowers = twitter.getFollowersIDs(user.getScreenName(), -1);
long[]fofIDs = followerIDsOfFollowers.getIDs();
for(long subId : fofIDs) {
twitter4j.User user1 = twitter.showUser(subId);
System.out.println("Follower Master:" + userScreenName +" Follower of Follower Name: " + user1.getScreenName());
System.out.println("Location:" + user1.getLocation());
}

Flickr 4 Java - How do you find pictures / metadata from a certain region? e.g. Vienna

Best
Goal :
Receiving geographic data(coordinates), time-stamps... . "From pictures taken in Vienna."
My question:
How can i do this in Java? (using flickrapi-1.2.jar)
What did i already found out? :
Give me the 500 most recent pictures - url's ... :s
public static void main(String[] args) throws FlickrException, IOException,
SAXException {
String apiKey = "123456789abcdefghijklmnopqrstvwuxz";
Flickr f = new Flickr(apiKey);
PhotosInterface photosInterface = f.getPhotosInterface();
Collection photosCollection = null;
photosCollection = photosInterface.getRecent(500, 0);
int i = 0;
Photo photo = null;
Iterator photoIterator = photosCollection.iterator();
while (photoIterator.hasNext()) {
i++;
photo = (Photo) photoIterator.next();
System.out.println(i + " - Description: " + photo.getSmallUrl());
}
}
Option : Good Examples or a decent manual is welkom, because i don't know exactly how this API works...
Kind regards
You need to call the flickr.photos.search API method.
With Flickr4Java it would look like this:
String apikey;
String secret;
// Create a Flickr instance with your data. No need to authenticate
Flickr flickr = new Flickr(apikey, secret, new REST());
// Set the wanted search parameters (I'm not using real variables in the example)
SearchParameters searchParameters = new SearchParameters();
searchParameters.setAccuracy(accuracyLevel);
searchParameters.setBBox(minimum_longitude,
minimum_latitude,
maximum_longitude,
maximum_latitude);
PhotoList<Photo> list = flickr.getPhotosInterface().search(searchParameters, 0, 0);
// Do something with the list

twitter4j: getting full name, bio, location, url of user (by username)

How do I get the full name, bio, location, and url of a user by knowing the username in twitter4j?
Twitter twitter = new TwitterFactory().getInstance();
User user = twitter.showUser(username); // this line
if (user.getStatus() != null) {
System.out.println("#" + user.getScreenName() + " - " + user.getDescription());
} else {
// protected account
System.out.println("#" + user.getScreenName());
}
returns
java.lang.IllegalStateException: Authentication credentials are
missing.
(tokens and so on are defined at the beginning. Tweeting, which also requires authentication of course, works fine with that)
You forget to pass the authentification to the TwitterFactory
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("CONSUMER_KEY");
cb.setOAuthConsumerSecret("CONSUMER_SECRET"));
cb.setOAuthAccessToken("TOKEN");
cb.setOAuthAccessTokenSecret("TOKEN_SECRET");
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
....

Categories

Resources