PayPal REST API not returning recurring payment information in laraval - laravel-5.8

I am working on Paypal webhook (subscription) section to insert recurring payment information into the database. I have done coding based on the link "https://jslim.net/blog/2018/01/22/PayPal-Rest-API-with-Laravel-5-and-Angular/" but Paypal webhook always return “payment_status: Pending” on sandbox image and its not inserting recurring payment information into the database (insert option added in PayPalController - function webhooksPaymentSaleCompleted ).
I think the problems related with routes/api.php file but I can't figure out what exactly is going wrong.
Another URL that I have referred and tried was "https://github.com/supermavster/PayPal-PHP-SDK"
Laravel version 5.8
paypal/rest-api-sdk-php: "^1.14"
Please suggest a feasible solution to this problem.
Thanks in advance.

Verify that the sandbox account's email is confirmed, by logging into the sandbox business account receiving the payment and navigating to: https://www.sandbox.paypal.com/businessprofile/settings/email
Resend the confirmation message. Open the message via https://developer.paypal.com/developer/notifications/ , and confirm the sandbox email.
The v1 PayPal-PHP-SDK is deprecated and there is no reason to be using it for a new integration. Use the v2 Checkout-PHP-SDK for payments.
You'll need two routes on your server, one for 'Set Up Transaction' and one for 'Capture Transaction', documented here; https://developer.paypal.com/docs/checkout/reference/server-integration/
The best approval flow to pair it with is https://developer.paypal.com/demo/checkout/#/pattern/server

Related

Should I call verifyBuyer for off-session payments

I'm integrating Square payment gateway into our system. And want it to support SCA.
In their dev docs it says that I should call verifyBuyer each time I want to charge CoF. Also, "If a challenge is required, Square automatically displays the challenge to the buyer". It's ok for on-session payments. But what about off-session payments, like cars rental service does - without customer online (automatically)?
In their dev docs it says nothing or I'm missing something.
Did anybody face with such case?
Our docs state:
Important
The SCA flow must not be initiated for a card on file transaction where the buyer is not present. In this scenario, do not call the verifyBuyer function. You can still charge the card but be prepared to handle the CARD_DECLINED_VERIFICATION_REQUIRED error.
Basically, don't call verifyBuyer, and don't pass a token to the payment endpoint. The payment could still technically fail, so you should build functionality to handle that.
https://developer.squareup.com/docs/payment-form/cookbook/verify-buyer-on-cof

No returned Phone Number in PayPal API

I checked the data return from paypal using dd() in laravel, but there is no phone number listed there. How can I get that data?
I'm using this package: https://github.com/paypal/PayPal-PHP-SDK
Screenshot:
Update - Added required phone in paypal settings
Solution
Use $payment->payer->payer_info->phone to access the phone number.
The $payment variable is a Payment class like the screenshot above.
I cannot guarantee this will be a valid solution, but PayPal says in its Express Checkout documentation that
Note: PayPal returns a contact phone number only if your Merchant Account Profile settings require that the buyer enter one.
So, start looking into the PayPal account, into your Merchant Profile settings: you should be able to find the option at one of the following the URL
https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-website-payments
https://www.paypal.com/businessmanage/preferences/website
Someone still have issue on receiving the info and got them by making a subsequent call to /v1/payments/payment/PAYMENT_ID.
(the above answer has been edited to simplify retrieving of all the info present in comments)
I got following from PayPal api book page 45.

Braintree drop in UI generate new nonce

I've integrated the braintree drop in UI in my project and have added paypal, google pay and visa payments. Everything works fine, payments are submitting to the API etc. But if I use submit a payment which fails using the values from - https://developers.braintreepayments.com/reference/general/testing/php#transaction-amounts. The nonce has then been used, amending my basket price and submitting again fails as the nonce has already been used. I've looked through the documentation and all I can find about nonces is that it can only be used once (https://developers.braintreepayments.com/guides/payment-method-nonces) and nothing around refreshing or requesting a new nonce. Ideally I'd like to avoid having to force the user to enter the payment details again.
Is there another way of automatically requesting a new nonce?

Validate whether payment was a success or failure

I am looking to use PayPal to accept a payment through my website. I am looking at the Smart Payment button option. If the payment is successful I need to update something in my website DB. How can I determine whether the payment was successful or not? I cant see anything the API docs.
I also need to retain user context with a PHP session ID. How can I pass that to the paypal site and ensure it is returned with the success / fail indicator?
Use Paypal IPN to receive payment notifications. Setup a server endpoint to respond to IPN requests and update your DB etc...
To maintain state, you will need to include a hidden input filed in your Smart Payment Button with a name of custom and a value of your choice (session id).
Setup a IPN endpoint ie: /checkout/ipn, to receive Paypal notifications. Capture the session ID with $_POST['custom'];
I ended up using the Braintree API for this use case. Ther Brantree API returns a unique payment identifier (payment Nonce) which you can then validate by submitting a call back to the Braintree API to ensure the payment was actually received properly.

Joomla AEC issue with Paypal, possibly IPN

I installed the Joomla AEC Version 1.0, Revision 5149.
I have set up plans and everything in this matter, if user clicks on the create an account system will ask user to select the plan. Then user clicks on buy now, she goes through Paypal, Purchase get made (Subscription with 3 days free trial) then user get redirected back to the site which all works fine.
My problem is user will see the message that says "Thank you for your registration. Our system will now await your payment. You will receive an e-mail once our system has processed your request. ". site will never get the clearance from Paypal. I havent put any custom custom URL or anything like that.
Also site is in the staging. so the URL starts with http://staging.domainanme.com
Not sure if this will cause an issue.
Thanks
With AEC it is quite simple with a Paypal Subscriptions processor. You just need to put in the email address of your account at:
Processors -> Paypal Subscritions -> Business ID
Not sure if that will be the same with 1.0 as this is based on 1.2.
If you have a valid account that's all you need. Of course make sure you have assigned the processor to your plan.
So if this all checks out one other thing you can try. If you were using the paypal account before with some other domain then switch to staging.domainname.com then you might want to try adding the Alternate IPN Notification Domain. Find this at:
Processors -> Paypal Subscritions ->Alternate IPN Notification Domain
In here put exactly http://staging.domainname.com
UPDATE:
The problem is Paypal communication then. First remove the Alternate IPN Notification Domain setting in AEC that I suggested. That was just for testing.
Either Paypal email is not confirmed so the communication fails or the communication can't be established.
Assuming you are using Paypal Standard, go to Paypal and login. Check in this order:
Click on Profile. Does the email have "unconfirmed" beside the email? If it does then that's your problem.
Go to Profile -> My selling tools -> Instant payment notifications. Click update on the far right. Enable it and add a new notification url. It should look like: http://www.yoursite.com/index.php?option=com_acctexp&task=paypal_subscriptionnotification
Just another thought. Paypal doesn't enable Paypal subscriptions when you sign up for Paypal Standard. I can't remember exactly when/how that was done but I remember that a separate step was needed. That could also be the cause of this issue.

Resources