Paypal Recurring Payments with initial payment creates & instantly cancels if user doesn't have balance - paypal

My PayPal recurring payment profiles have an initial payment.
My backend checks for canceled payment profiles. If the profile is canceled the subscription on my website ends at the canceled profile's expiration date (this is so people who pay for a subscription and cancel afterwards keep their website subscription until the subscription end date).
When the user doesn't have any balance or payment method bound to their PayPal, they can still create the payment profile. PayPal allows users to click 'Agree & Pay Now' and notifies my backend even though the initial payment isn't made (because the user has no paypal balance or valid payment method).
In my payment history I can see the profile has been created and canceled instantly without a payment made.
Is there a way to simply not accept payments if the initial payment hasn't gone through?

To capture the initial payment the best way is to call the doexpresscheckout API for the initial amount and then create recurring profile using the same token . In this way , if the doexpress checkout call is successful this means you receive your initial payment and their funding source also is good . Once this step is successful you can procees to create recurring profile .

Related

How to interprete paypal billing agreement creation?

I am building a paypal subscription system but i have some difficulties to understand some points. When using sandbox i can't simulate a payment denial process so when the payment is made, paypal redirect me to my "approval url callback" and a billing agreement is created.
So i want to know , in a real situation, will paypal redirect me to the approval url and create this billing agreement even if the payment didn't occur yet ? or this one can be created if and only if the payment is accepted ? (So if paypal denied the payment the billing agreement will never be created)
In my case, my customers will need to access to some paid features of my website so, should i wait for the "ipn webhook notification (PAYMENT.SALE.COMPLETED)" which can take several minutes to be fired to my endpoint, or can i grant access immediately after the billing agreement is created ?
Which is the most secure thing to do ?
thanks.
If the user cancels the checkout, Paypal will redirect to your cancel URL.
But the failed payment cases are not clear to me either. I believe that the agreement will be created even if the payment fails, since it needs to exist for the payment attempt to be done, but I don't work at Paypal :).
My approach is to activate the subscription on a successful redirect no matter what, [edit: the execute response returns an agreement_details.next_billing_date in the past, so you can't use that] with a short initial subscription expiration (4h). When our webhook receives a PAYMENT.SALE.COMPLETED message, we fetch the agreement billing agreement details, and update the subscription expiration to the new agreement_details.next_billing_date. But if the webhook receives a PAYMENT.SALE.DENIED, we just let the subscription expire.
HTH.

Paypal recurring payment enough money

I'm testing recurring payment on Sandbox of Paypal.
But I find out client's account is not enough money, but their own account is still recieved money.
If client 's account is not enough money, how does the paypal process?
This transaction will be suspend or cancel...
If client'account have enough money then the transaction become activate.
For initial payment, use FAILEDINITAMTACTION, Action you can specify when a payment fails. It is one of the following values:
ContinueOnFailure – By default, PayPal suspends the pending profile in the event that the initial payment amount fails. You can override this default behavior by setting this field to ContinueOnFailure. Then, if the initial payment amount fails, PayPal adds the failed payment amount to the outstanding balance for this recurring payment profile.
When you specify ContinueOnFailure, a success code is returned to you in the CreateRecurringPaymentsProfile response and the recurring payments profile is activated for scheduled billing immediately. You should check your IPN messages or PayPal account for updates of the payment status.
CancelOnFailure – If this field is not set or you set it to CancelOnFailure, PayPal creates the recurring payment profile, but places it into a pending status until the initial payment completes. If the initial payment clears, PayPal notifies you by IPN that the pending profile has been activated. If the payment fails, PayPal notifies you by IPN that the pending profile has been canceled.
Once you are into the regular billing cycle, Be sure to assign a value to MAXFAILEDPAYMENTS, which is the number of scheduled payments that can fail before the profile is automatically suspended. An IPN message is sent to the merchant when the specified number of failed payments is reached.
Then, AUTOBILLOUTAMT Indicates whether you would like PayPal to automatically bill the outstanding balance amount in the next billing cycle. The outstanding balance is the total amount of any previously failed scheduled payments that have yet to be successfully paid. It is one of the following values:
NoAutoBill – PayPal does not automatically bill the outstanding balance.
AddToNextBilling – PayPal automatically bills the outstanding balance.
it is up to you how to handle profiles that suspend.

PayPal handling of subscr_eot if user switch to different subscription?

Here is the scenario:
on 25/3 user purchases a basic monthly subscription (recurring payment profile)
on 7/4 user cancels basic monthly subscription and start a premium monthly subscription (a different recurring payment profile)
Now my question is whether I am going to receive a "subscr_eot" on the 25/4 (referring to the first basic monthly subscription) or is PayPal smart enough not to send subscr_eot since the user has started a new recurring payment profile with me?
I would like to set the user profile to "no subscription" as soon as I get a "subscr_eot", but I am not sure whether I can trust PayPal to notice that a new subscription was started between cancellation and end_of_term.
If it's canceled then the end of term was never reached. In such a case you'd get an IPN with txn_type=subscr_cancel. You would then get another IPN with txn_type=subscr_signup when the new profile is created.
That is assuming you're using standard subscriptions. You specifically mentioned subscr_eot, so that's why I made that assumption. However, you also mentioned "recurring payment profile". The Recurring Payments API is separate from standard subscriptions and would have different txn_type values for IPN, so if that's what you're actually using you'll need to adjust accordingly.

Paying automatically from PayPal

I need to know if the following scenario can be developed.
I have a website where the mode of payment is pay-by-usage. So when the customer exceeds a particular amount, I need to charge his PayPal account automatically. Is this possible in the PayPal API?
You can use PayPal Adaptive payment and there is an option to charge user account automatically. It is called PayPal Pre Approval payment.
In the first phase the user has to authorize your app to perform payment onbehalf of user. During this authorization step, you will get and authorize pre approval key. Later you could automatically charge user PayPal account using this key.

Paypal Recurring Payments find if payment is dont or not

i am integrating paypal recuring payment where Ist month payment is free. and after it is chargebal. my probleam is after making payment profile of user how i find if this month payment is done or not of this particular profile.
You can log into your account and view the profile, it will show you the payment history for that profile. If you are using IPN, you could set up a backend system for recording this information and viewing it. Every time a payment is completed, you will get an IPN, which you would just have your system write it to the database.