Paypal add custom_id directly in order url - paypal

Can I attach custom_id to paypal order link like that (&custom_id=${customId})? Or in order to add custom_id I MUST use paypal-js?
https://www.paypal.com/webapps/billing/plans/subscribe?plan_id=${plan_d}&custom_id=${customId}

It cannot be added to a URL, you need to create the subscription for every checkout attempt.
You can create the subscription using the JS SDK, which gives the best in-context approval flow (not redirecting away from your website, keeping it loaded in the background) -- or you can do so with the REST API and get a link for approval, which is an older flow.

Related

Upgrading PayPal payment to Orders API, the testing account didn't receive any money after finish the payment

I'm trying to implement the new PayPal Orders API, here is what I did:
Create a developer account, add an app name and then I have Client Id and Secret.
Use OrderCreateRequest to create an Order
Get approvel_url from the resposne->result->links
Redirect to this approvel_url and finish the payment
Paypal will redirect back to my website.
But I never got any thing from the PayPal testing account,Please, what did I miss?
Edit:
On No.4, when redirects to the PayPal page, somehow it only shows 'Continue' button on the page, not the 'make payment' button.
You are missing:
Display an order review page to the payer.
Capture the order with an API call, which (if successful) will return the transaction ID in the purchase_units[0].payments.captures[0] object.
On success, display a thank you/confirmation page.
Without the final capture API call, there is no PayPal transaction.
You are also still using an old integration method based on redirects, which is for old websites. Current PayPal Checkout integrations use no redirects. At all.
Instead of redirecting, make two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return only JSON data (no HTML or text). When a capture response is successful, store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) right before sending your return JSON.
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

I can't find out transaction history in sandbox use paypal checkout-sdk

I use java checkout-sdk-1.0.4 to develop PayPal payment. I successfully submit an order to PayPal, get the payment url.
I log in with personal account and click the continue button.
And then paypal just redirect to the url i set.
http://localhost:38001/checkout/submit/result?token=60X99286YV4394812&PayerID=9WXE2YPSNEJSN
I can see the api call history in developer dashboard.
But i can't see any transaction history in my business account and personal account.
How do I determine if my payment is successful。
I try this tutorial from here
https://developer.paypal.com/docs/business/checkout/server-side-api-calls/create-order/
https://developer.paypal.com/docs/business/checkout/server-side-api-calls/capture-order/
At the end, paypal return capture success.
Status Code: 201
Status: COMPLETED
Order ID: 1AL061567P026410J
Links:
self: https://api.sandbox.paypal.com/v2/checkout/orders/1AL061567P026410J
Capture ids:
6NY33838LX3268618
But i still can't see transaction history in my personal test account.
But I can't see any transaction history in my business account and personal account. enter image description here
You can't see any transaction because there is no transaction. There won't be any, unless you show the required order review page and perform the required capture API call when the customer returns to your site. (if you want to skip showing a review page and proceed directly with making the API call, then you should set the application_context object's user_action to 'PAY_NOW', so the last button's text is changed from 'Continue' to 'Pay Now' and the user knows to expect no review page. You still need to perform the API call to capture regardless).
The flow you are using of redirecting over to PayPal and then showing a review page or doing a capture call after being redirected back, is an old checkout flow and does not provide the best user experience. It is better to not use any redirects. At all.
Instead, make two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return only JSON data (no HTML or text). The latter one should (on success) store the payment details in your database before it does the return (particularly purchase_units[0].payments.captures[0].id, the PayPal transaction ID)
Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

Automatically capture a order in PayPal

I'm integrating my application with PayPal and i found a problem.
I use PayPal REST API with intent: "CAPTURE".
After I create an order in paypal via /v2/checkout/orders POST endpoint and client pay for this order in https://www.sandbox.paypal.com/checkoutnow?token={TOKEN} website I don't receive any money or transaction on my PayPal business account.
When I check this order status it says that it is APPROVED but not COMPLETED, so i need to capture this order via v2/checkout/orders/{TOKEN}/capture POST endpoint. After capturing this order is has status: COMPLETED and i receive money.
Is It possible to automatically capture an order without any additional request to capture it?
Because when I use PayPal button It works automatically and I want to have the same result using REST API.
No, it's not possible. The capture step is required.
Whether you use a client-side integration: https://developer.paypal.com/demo/checkout/#/pattern/client
Or a front-end UI that calls server-side routes of yours: https://developer.paypal.com/demo/checkout/#/pattern/server
The capture step after approval (within onApprove) is always required.

Paypal sandbox showing wrong STORE name

I have tested my paypal payment with sandbox account using my API details. Now I want to use Clients API details for sandbox and changed code accordingly. But it still redirects me to the previous store.
Any idiea what is wrong i am doing.
it looks like your code didn't change the API credentials in some way. Try to check again the new APIs that you want to use and replace the previous one.
Usually, for example in ExpressCheckout, when you initially call the SetExpressCheckout you provide the API credentials of the seller so that when the checkout is displayed you can connect to the seller shop to pay and all the money will be directed there.

How app can get PayPal user transaction info?

Can I get notification with data at specific url when users who connected PayPal to my app throught Oauth2 will get payment? I know it possible with IPN, but then each user need to add my url in their account settings. Is any another way?
Update: Or can I manually get information about last user transactions(completed outside my app)?
There are a number of ways to accomplish what you're trying to do, I think.
You mentioned IPN, and that would be the best way. You can specify the NotifyURL in your standard button code or API requests (depending on how you're setting up the payments) so that IPNs for those payments will be sent to your IPN URL. That way you don't have to have users set that up in their own account.
Alternatively (or in conjunction with), you could use the Permissions API to allow users to authenticate your app to make API calls on their behalf. Then you can use the TransactionSearch and GetTransactionDetails APIs to pull any info you need about their account transaction history.