PayPal Community Chat - September 21, 2018 - Closed

PayPal_Martin
Moderator
Moderator

Hey everybody!

 

Join the PayPal Community Forums moderation team in our semi-weekly Community Chat on Friday, September 21st, from 4-5pm GMT.

 

Our moderator staff will be here to answer your questions regarding PayPal. This thread will remain locked until the chat is open, so if you have a question you'd like to see answered by the community before then, please feel free to post a topic by clicking on "Post a Topic" and selecting the appropriate board.  As always, PayPal customer service can be reached by clicking on "Contact Us" and selecting help via phone or email.

 

How Community Chat works:

 

The chat opens at 4pm GMT. Once the chat is open, PayPal Community members may participate and ask questions by using the "Reply to topic" button.

 

In order to post in the chat, you must be a PayPal Community member. If you'd like email updates on the chat, click the "Options" menu and select Subscribe. Smiley Happy 

 

During the chat, PayPal Moderators will answer general PayPal questions in real-time. 

 

At 5pm GMT, the chat will close and lock. Any questions that have not yet been responded to by a moderator or employee will receive a response within the following hour.

 

Please feel free to RSVP to the chat by clicking "Me too" at the bottom of this post.  See you then!

 

Martin.

Login to Me Too
13 REPLIES 13

manjiltamang
Contributor
Contributor

Hi, I created a very simple program with the help of paypal's api docs. The code is fairly simple. Program works correctly as it should, it even shows the success response when payment is executed through return url.

But the amount is not being added from seller account to the merchant account. Any help would be appreciated. Thanks!

 

Here's my code.

 

@Configuration
public class PaypalConfig {
	
	@Value("${paypal.client.app}")
	private String clientId;
	@Value("${paypal.client.secret}")
	private String clientSecret;
	@Value("${paypal.mode}")
	private String mode;
	
	@Bean
	public Map<String, String> paypalSdkConfig(){
		Map<String, String> sdkConfig = new HashMap<>();
		sdkConfig.put("mode", mode);
		return sdkConfig;
	}
	
	@Bean
	public OAuthTokenCredential authTokenCredential() {
		return new OAuthTokenCredential(clientId,clientSecret,paypalSdkConfig());
	}
	
	@Bean
	public APIContext apiContext() throws PayPalRESTException{
		@SuppressWarnings("deprecation")
		APIContext apiContext = new APIContext(authTokenCredential().getAccessToken());
		apiContext.setConfigurationMap(paypalSdkConfig());
		return apiContext;
	}
	
}

@Autowired
private APIContext apiContext;
 
@GetMapping()
public String paypalPay(HttpServletRequest req) {

// Set payment details
Details details = new Details();
details.setShipping("1");
details.setSubtotal("5");
details.setTax("1");
 
// Payment amount
Amount amount = new Amount();
amount.setCurrency("USD");
// Total must be equal to sum of shipping, tax and subtotal.
amount.setTotal("7");
amount.setDetails(details);
 
// Transaction information
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setDescription("This is the payment transaction description.");
 
// ### Items
Item item = new Item();
item.setName("Ground Coffee 40 oz").setQuantity("1").setCurrency("USD").setPrice("5");
ItemList itemList = new ItemList();
List items = new ArrayList();
items.add(item);
itemList.setItems(items);
 
transaction.setItemList(itemList);
 
// The Payment creation API requires a list of
// Transaction; add the created `Transaction`
// to a List
List transactions = new ArrayList();
transactions.add(transaction);
 
// ###Payer
// A resource representing a Payer that funds a payment
// Payment Method
// as 'paypal'
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
 
// Add payment details
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
// payment.setRedirectUrls(redirectUrls);
payment.setTransactions(transactions);
 
// ###Redirect URLs
RedirectUrls redirectUrls = new RedirectUrls();
String guid = UUID.randomUUID().toString().replaceAll("-", "");
redirectUrls.setCancelUrl(req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort()
+ req.getContextPath() + "/paypal/payment/cancel?guid=" + guid);
redirectUrls.setReturnUrl(req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort()
+ req.getContextPath() + "/paypal/payment/success?guid=" + guid);
payment.setRedirectUrls(redirectUrls);
 
// Create payment
try {
Payment createdPayment = payment.create(apiContext);
 
// ###Payment Approval Url
Iterator links = createdPayment.getLinks().iterator();
while (links.hasNext()) {
Links link = links.next();
if (link.getRel().equalsIgnoreCase("approval_url")) {
// System.out.println(link.getHref());
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
// req.setAttribute("redirectURL", link.getHref());
return "redirect:" + link.getHref();
}
}
 
} catch (PayPalRESTException e) {
System.err.println(e.getDetails());
return "redirect:/paypal/error";
}
// System.out.println("Success url: " + redirectUrls.getReturnUrl());
// System.out.println("Payment id"+ createdPayment.getId());
// return createdPayment;
return "redirect:/paypal/error";
 
}
 
@GetMapping("/payment/success")
@ResponseBody
public String executePayment(HttpServletRequest req) {
APIContext apiContext = new APIContext(clientID, clientSecret, mode);
 
Payment payment = new Payment();
payment.setId(req.getParameter("paymentId"));
 
PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.setPayerId(req.getParameter("PayerID"));
try {
  Payment createdPayment = payment.execute(apiContext, paymentExecution);
  System.out.println(createdPayment);
  return "Success";
} catch (PayPalRESTException e) {
  System.err.println(e.getDetails());
  return "Failed";
}
} 
Login to Me Too

PayPal_Martin
Moderator
Moderator

HI @manjiltamang,

 

Welcome to our Community Chat!

 

I would suggest in the case you reach out to our Merchant Technical support team, you reach them @PayPal_MTS or alternatively, you can contact them directly through the Technical Support website here https://www.paypal-techsupport.com/.

You can sign up and submit a ticket with details of the issue. A dedicated member of pour technical team will answer your specific issue.

 

Thanks

 

Martin

Login to Me Too

bp_Oblivion
Contributor
Contributor

can i ask about account limitations here? Haven't gotten a message back from the support team.


Login to Me Too

PayPal_Martin
Moderator
Moderator

Hi @bp_Oblivion,

 

Welcome to our Community Chat!

 

Unfortunately, as we are unable to see or discuss your account through the Community, you should try contacting us directly via Twitter @AskPayPal or via Facebook https://www.facebook.com/PayPal and we can look into this further for you.

Account limitation can be quite complicated, so make sure you resolve all the steps in the Resolution Centre. If you have an issue with a step or cannot resolve it, please respond with the reason you cannot. 

Only when all steps are completed will the case get reviewed, unless you contact our Customer Support directly to escalate the case on your behalf.

 

Thanks

 

Martin

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.