Paypal express checkout java - java

I'm integrating paypal express checkout on one website and I'm using PaypalFunctions.java that I've download in the customized example.
I've successfull called, in development environment, the ppf.callMarkExpressCheckout
and after login on Paypal page I've correctly reached my confirmation page where i catch the payerId from the request.
I can't understand if the process is complete or I need to make a further step to get money and end the process.
I have this doubt because the process and the methods name is quite different than the one described in https://developer.paypal.com/docs/classic/express-checkout/gs_expresscheckout/ and I don't receive any mail from paypal dev environment
Kind regards

In express checkout , once the buyer comes to your return url after confirming the Payments from their account you need to call the "DoExpressCheckout" API using the token and the payer id you received on your return url . Until this step completes , No payment will be recorded and hence no emails will be sent out . You can check the documentation for "DoExpressCheckout " API here :
https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/ht_ec-singleItemPayment-curl-etc/

If I got you right, you don't know how pay pal gets back to you. Look for 'returnUrl' (and 'cancelUrl') in https://developer.paypal.com/docs/classic/express-checkout/gs_expresscheckout/ . That's URL pay pal calls on your application once the user authorized the payment on the pay pal site.

Related

Complete the payment process with PayPal Java and get the status whether it is completed successfully or not

to integrate PayPal payment into Java web application ,i use this link Text,
but when i verify the paypal sandbox account for both buyer and seller i found the transaction will be added but it has a "pending" status and the money is not changing,so i want to complete the transaction to transfer money from buyer to seller and paypal inform me whether the transaction is successful or not.
I found the transaction will be added but it has a "pending" status
There are a few possible reasons for this, one is simply the expected behavior of requestPayment.setIntent("authorize");. You may simply want to change that to "sale" if it's not being captured automatically by the guide you were following.
Another possible reason is the currency if it is new to that sandbox receiver account. Log into the receiver account via https://www.sandbox.paypal.com , and see if you can accept one of the payments in the new currency, which will open a currency balance. Future payments won't be pending.
Also ensure the sandbox Business account receiving the payment has a confirmed email in the sandbox environment...
Log into it at https://www.sandbox.paypal.com/businessprofile/settings/email
Send the confirmation from there, if necessary
Read and proceed with the confirmation, via https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fnotifications%2F

Paypal return url not working for sandbox account

I am trying to integrate paypal with spring boot application. I am using sandbox account for testing. I have successfully generated the order , order is generated and user is rediected to paypal to excute payment, when he clicks on cancel order , my localhost cancel order api is successfully called by paypal.
But when user(sandbox personal account) wants to continue the payment he is not able to do so. Payment is not being executed and he is redirected again to that continue payment page.
https://www.sandbox.paypal.com/webapps/hermes?flow=1-P&ulReturn=true&token=EC-7YJ233484C422661Y&hermes=1&fromLite=1#/checkout/selectFi
This url is called by paypal instead of return url which was set in the code.
This page is called again and again on clicking continue(I am randomly entering the cvv as it was not provided in the personal sandbox account.)
Please help !!
I believe there is currently a bug when paying with an Indian buyer account in the PayPal sandbox.
Try paying with a buyer from a different country, for example a US Personal account created at https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F
You may need to temporarily change your integration's currency from INR to something else, for example USD.
This seems to only be a problem with the sandbox simulator for IN / INR transactions

Paypal subscription integration full cycle missing in documentation?

I already have an implemented CMS system where the user creates the subscription plans.
I want to integrate my CMS server with Paypal so when the user creates a plan it will be created on Paypal servers.
I can see how to do that in https://developer.paypal.com/docs/subscriptions/integrate/
But the problem is there is no documentation for the front-end side for the subscription step ! How should i redirect the customer to Paypal to login, and how will i receive the data to send it to my server ?
Note : Since i want my user to create plans only on my CMS, there is no easier way to integrate with paypal than this : https://developer.paypal.com/docs/subscriptions/integrate/ .. right?
i don't want to use Smart Buttons so the only option i have is to integrate with APIs.. if there is any easier way please tell me.
This is a bit hidden.
When you create a subscription, its status will be set to APPROVAL_PENDING. Look for the "rel": "approve" link in the response (in links). The URL will look something like this:
https://www.paypal.com/webapps/billing/subscriptions?ba_token=xyz
This is the URL you need to redirect the customer's browser to. Once they click on "Subscribe" to approve it, PayPal will redirect their browser to the return_url value you set when you created the subscription.
PayPal adds 3 extra parameters to that return URL: subscription_id (self-explanatory), ba_token (the approval token), and token (???). At that point, you can get the subscription details from PayPal, and its status should now be "ACTIVE".
Now I just need to figure out why next_billing_time is set in the past, and why I'm not receiving the PAYMENT_SALE webhooks :)
Hope this answers your question.

Paypal Sandbox payment state pending

I am using the (Java) Rest API to perform payments directly from credit cards in the sandbox. The payments all receive "pending" status, which according to the docs (https://developer.paypal.com/webapps/developer/docs/api/#create-a-payment) is not even a valid state to be returned by the payment create call. Payment review is disabled.
I would like to see the process through and complete the transaction. How do I do that in the sandbox? Or should I receive a different state right away?
Under http://developer.paypal.com, Application tab, find out the email associated to the REST app.
Now click on "Sandbox accounts", Click on the REST app email, click on "Profile" link.
Select "Setting" tab, and turn off "Payment review". You shall get "Approved" payment and "Completed" Sale json object.
this is the same issue with paypal status is pending so answer should be the same, just check the seller's selling preferences on the sandbox account like Max-P said, this is just different currency and config issue on paypal

Scribe - multiple callback simultaneously

I am making a module for a server software that is allowing support for facebook.
The problem is with the callback URL. If one client start the authorization proccess, then another client starts the proccess at the same time, or before the first user finish. How could I check what user finished first?
I need a way to check what client's callback I'm getting. One solution would be to lock other from register until the first one has finished, but I don't want to do that. Is there another way? I have thought about including ?client=clientid at the end of the callback, but I heard facebook only allows the exact url specified in the app on facebook.
UPDATE
It didn't work to add client="clientid" to the callback. Any other ideas?
After some more searchig I figured facebook will allow a parameter: state. (thanks to #jacob https://stackoverflow.com/a/6470835/1104307)
So I just did ?state=clientId.
For anyone using scribe the code is this:
service.getAuthorizationUrl(null) + "&state=" + clientId;
I think there is no problem on adding and GET parameter like client=clientID. Facebook will redirect you to the URL you have specified and using the REQUEST parameters you can check who completed the request. The problem exist if you have specified URL as http://yoursite.com and pass redirect to http://some-sub-domain.yoursite.com or entirely different location.
if you are using the server-side flow then the oauth 2 flow will be:
redirect user to facebook
facebook then rediects the user to your specified callback
your server uses something like curl to get the access token
your server does some more curl to get maybe more user data or update the user's data
my recommendation would be to set a session cookie in step 1 and simultaneously store this session id on your server. then the session cookie will automatically be sent to the callback url in step 2 and you can identify the session in the database this way.
this will work for all service providers (google, twitter, linkedin, etc) and is the preferred way of maintaining session continuity.

Categories