How to test a PayPal capture API call with Sandbox - paypal

I have setup PayPal Sandbox test accounts, a Personal (buyer) and a Business (merchant).
I'd like to test a PayPal 'DoCapture' API Operation. The problem I'm encountering is that I need an AuthorizationID and don't know how to obtain it. If i run the 'DoExpressCheckoutPayment' API call, I do not get an AuthorizationID returned, using the merchant API credentials, though I do get an 'ACK' of success. Do I need to be using the buyer credentials with the 'DoExpressCheckOutPayment' call? I don't see the API credentials in the PayPal Sandbox profile for the Personal account.

Express Checkout example with authorization and capturing you can find here.
Short answer - according with DoCapture documentation
AuthorizationID ... This is the transaction ID returned from DoExpressCheckoutPayment...
According with DoExpressCheckout documentation you need field from response, attention, PaymentInfo#TransactionId
... this value is your AuthorizationID for use with the Authorization & Capture APIs.

This is what you need to do to implement the capture API.
Create Payment: set intent as authorize in its request to get payment Id
Show Payment Details: to get approval_url. The customer will use this URL to pay for the order.
Execute approved PayPal payment: Use this API after customer successfully pays for the order. This API returns authorization-id along with capture link.
Use Capture API: use the URL obtained from step 3 to capture.
Use this link and check payments API.
https://developer.paypal.com/docs/api/payments/#payment_execute
Hope this helps to someone who stumbles upon here.

Related

CyberSource: Retrieve Capture Token from PayPal Transaction Details

I'm trying to retrieve the capture request token from past PayPal transactions as I need that for refunding customers. We don't have that info anywhere on our systems anymore because, just don't even ask. It looks kind of like this:
AxjrrwSTQDiO3h+N6P5RABJPE8jCJjo7f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=
Is it possible to get that?
I looked at PayPal's Transaction Search API here and nothing in the response says that field exists:
https://developer.paypal.com/docs/api/transaction-search/v1/
I have also checked the built-in reports on PayPal but they don't give us that either.
Furthermore, I have tried the REST API with CyberSource and that doesn't provide the Token either:
https://developer.cybersource.com/api-reference-assets/index.html#transaction-details
I have the PayPal Generated Transaction ID, the dates, our reference numbers, etc. All I need is that Capture Request Token. I will then be able to refund customers using CyberSource.
Any help or ideas would be most appreciated.
That's a CyberSource token, so you won't find it anywhere within PayPal.
The PayPal REST API itself (no CyberSource) doesn't require it for refunds, only the transaction ID: https://developer.paypal.com/docs/api/payments/v2/#captures_refund

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 webhook instead of return url

Here is my flow of the payment.
Create Payment and return Url for user to verify
Using above Url user opens Paypal account and accepts payment
After accepting payment Paypal returns to success url.
Execute payment (final stage of the sale)
My Question is if there exists any webhook triggered after step 2, before step 3. Right after user verifies payment in it's personal paypal page.
The reason to catch webhook is not to rely on success redirect url rather than use webhook.
The terms you are using do not match the keywords you've used here.
Are you working with REST APIs or are you working with PayPal Standard / Classic APIs?
If you're working with REST APIs, then the simple answer is yes, you should use the Webhooks to handle any automated processing. Specifically, take a look at the SALE Webhooks. That should give you what you're after.
If you're working with Standard / Classic, the answer is the same except that you would use IPN instead of Webhooks.

Validate PayPal Client id

I have been trying to validate Paypal client id but I didn't landed to any solution from Paypal documentation and also from other sources.
Anyone please help me if there is any API to validate Paypal's Client id.
You may want to look at PayPal Adaptive Accounts API. You can use GetVerifiedStatus API Operation to determine whether the specified PayPal account's status is verified or unverified.

Paypal Subscription Details

Can you help me. I need to know if PayPal has an API call to get subscription details like the enddate of the subscription?
I do the request to PayPal and get the response,
SUCCESS
transaction_subject=Name20
payment_date=10%3A42%3A50+Mar+28%2C+2014+PDT
txn_type=subscr_payment
subscr_id=I-MWMMATTBSY2M
last_name=jls
....
but I need details from suscription as enddate.
Sounds like you're using Standard Subscriptions and the "response" you're referring to would be an Instant Payment Notification (IPN)..??
Unfortunately, the standard subscriptions system doesn't have any API's to access details directly. You could switch to Express Checkout and the Recurring Payments API, though, and this would give you access to API's to obtain details and manage the profiles programatically.
If you're working with PHP you can setup Express Checkout and Recurring Payments very easily using my class library for PayPal.
The flow you'll be setting up would be as follows...
1) Call SetExpressCheckout to obtain a token and redirect the user to PayPal. The SEC request will also include a ReturnURL which is where PayPal sends the user after they've signed in and agreed to continue. You also need to make sure to include the Billing Agreement parameters in your SEC request so that the token you get will be compatible with recurring payments.
2) The user ends up back at your ReturnURL, and this is where you'll call GetExpressCheckoutDetails to obtain details about the buyer that the system now knows since they've signed in. This gives you info like the payer's name, email, address, etc. It also gives you the Payer ID you'll need for the final request.
3) Right after obtaining the details via GECD you'll call CreateRecurringPaymentsProfile to finalize the subscription profile creation.