Braintree - Callback When Payment Method Changes - paypal

Is there a callback in the Braintree drop-in for when the user changes the payment method? I see there is onPaymentMethodReceived but it's called when the form is submitted. I need a callback when the payment method changes.
Basically, what I need is a way to know when the user selects "PayPal" as the payment method.

Full disclosure: I'm a developer at Braintree. If you have any further questions, feel free to contact support.
Right now we don't have a callback for the Drop-in that is called when the payment method is updated. If your main usage of the Drop-in is to be SAQ A compliant, it is worth it to check out Hosted Fields. Hosted Fields let you custom build your own payment method forms, with the actual form input handled on Braintree servers. This also allows you to customize your integration more than the Drop-in, which would let you build your own payment method picker, and implement any callbacks necessary to detect a change in payment method selection.

Related

Payment method for automatic charges when event is completed

I want to build an mobile app with flutter that gets payment when event is done.
for example, i call a taxi from an app and app is calculates payment from distance, time etc.when finish driving button tapped, app is gonna take payment from saved credit card immediately no 3d secure or anything.
my question is what is that payment method called, how can i implement that service (stripe, paypal etc.)
You can integrate Stripe payment services.
There are two ways you can choose to start:
Install and use Stripe via Firebase Extensions
Install and use Stripe via Dart Packages
I recommend them as they are very well documented and supported by Flutter.
With PayPal, charging from a user account on file is variously called "reference transactions with billing agreements" (Classic API), or reference / customer not present transactions with Vault in newer APIs.
To use reference transactions, the PayPal account must first be approved for it. You can contact the business support and explain the business need for the feature. Alternatively you look into getting PayPal's Braintree service which always has reference transactions enabled.
Provided reference transactions are approved and enabled on an account (which it must be emphasized is something the business side does, not a technical matter), PayPal can then guide you on which specific API to use.

PayPal Subscription Cancellation - Webhook

From a developer perspective, what is the best way to capture (webhook wise) a user cancelling their PayPal subscription via their dashboard (and/or subscription payment failing)?
I've had some discussions with PayPal support and have learnt the following:
Subscription button:
-simple, elegant, works well to let user subscribe
-however, when user cancels subscription via their dashboard does NOT fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Only an IPN HTTP "webhook" gets fired. From the paypal docs, IPN seems harder to integrate (not REST, and for example the IPN simulator doesn't even have "subscription cancellation" events)
Using API (PayPal PHP SDK):
-DOES fire BILLING.SUBSCRIPTION.CANCELLED webhook events when user cancels their subscription via their PayPal dashboard (why this doesn't work for button-created subscriptions I do not understand)
-However, seems much more complex to set up than the button (what does the web flow look like?)
Just some thoughts on the best approach would be appreciated.
It depends on the type of 'Subscribe' button.
Legacy 'Subscribe' buttons created via e.g. https://www.paypal.com/buttons , will not fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Those buttons predate webhooks by 10 years, and only use the very old IPN service. Stay away...
Current smart subscribe buttons, created via e.g. https://www.paypal.com/billing/plans or following the documentation do trigger the BILLING.SUBSCRIPTION.CANCELLED webhook.
In general, you can make use of the CANCELLED webhook and track this status if you want to but it's not necessary. The most important best practice is to make use of PAYMENT.SALE.COMPLETED and record when a subscription was last actually successfully paid for. If it doesn't get paid for again on time, then it's lapsed and you treat it accordingly.
When creating a subscription, along with the plan_id you can pass a custom_id which will be returned in all the webhooks. This can be useful for reconciliation purposes so you know which user it's for.
Using API (PayPal PHP SDK):
That SDK is deprecated, don't use it. Any API calls should be done directly via HTTPS.

PayPal Subscription API, Smart Payment Button and custom variables

I am trying to set up a recurring payment with PayPal Subscription REST API. I'm following the Basic Integration in PayPal Developer Portal, using as suggested the Smart Payment Button. Besides, I'm using a WebHook to "capture" events related to subscription.
As the tutoria suggest, I created a Product and a Plan.
Now, I rendered the Smart Payment Button in a page (using the example), and when clicked it triggers the PayPal authorization flow. When the user complete the subscription process, the BILLING.SUBSCRIPTION.CREATED event is triggered. Later, also the PAYMENT.SALE.COMPLETED and BILLING.SUBSCRIPTION.ACTIVATED are triggered, and I receive data in my WebHook. Now, I have troubles in identifying which user activated the subscription. My idea is to pass a custom variable (with something allows me to identify the user) and retrive it later when the WebHook post me data, but I can't undertand how to do it. Anyway, is this the best way to do it? Or there is another solution?
I solved this using "custom_id" in the smart button:
return actions.subscription.create({
'plan_id': 'PLAN_ID',
'custom_id': 'CUSTOM_ID'
});
Then, I receive custom_id from webhooks or querying the subscription.

Paypal Buy Now does it trigger webhooks of received payment?

Does Paypal "Buy Now" button triggers webhooks?
What's the disadvantage of using the Buy Now button versus a fully integrated payment system in a website selling digital goods?
PayPal buttons trigger webhooks called IPN (instant payment notification). You can define a controller to handle this request and update your database.
The button you put on your web site can include custom fields that will be sent back by the IPN (along with all information sent by default, such a price, etc) , making it easier to identify the payment (such as the identifier of the customer in your application).
I can elaborate and add some code later. Unfortunately I’m on my cellphone right now.
I cannot compare to other methods, as I have only worked with PayPal buttons and IPN, but it’s quite easy to make it work.
https://developer.paypal.com/api/nvp-soap/ipn/IPNIntro/

cancel paypal subscription from my cart

as stated here: Detecting Paypal Subscription Cancellation api can be used to detect a paypal subscription cancellation. what about the opposite? using magento, i have code that creates the paypal subscription but when i cancel the subscription (in the cart), the cancellation is not passed to paypal and i must then go to paypal to cancel.
it would be great to avoid the extra step of double canceling and just only have to cancel from my cart (as admin and as customer via api sent to paypal)
You can use the ManageRecurringPaymentsProfileStatus API to cancel "I-" profiles. As far as if Magento supports this, or if there is a plugin that you can use I don't know of one off hand. However, it is possible. All that needs to happen is that your cart just needs to make API call.