Create and approve PayPal subscription after invoice status is paid - paypal

I am generating one PayPal invoice through API and send it to user for payment. after the user pays that invoice the status of invoice is changed to paid. Now I need to start a subscription because the user paid the invoice.
When I create a subscription it always give me "approval-pending" status . I want to set subscription status as "Active" because the user already paid for it through the invoice.

Invoicing and Subscriptions are two separate things. There is no crossover between them. You use one, or you use the other, as their own ways of receiving a payment.
To send an invoice from a PayPal account, use:
live: https://www.paypal.com/invoice
sandbox: https://www.sandbox.paypal.com/invoice
...or the invoicing API as desired.
To create and manage subscription plans, use:
live: https://www.paypal.com/billing/plans
sandbox: https://www.sandbox.paypal.com/billing/plans
... or the Subscriptions API if desired. In the account interface after setting up a plan, use the three dots menu to copy button code or a link for it. Alternatively, follow the subscriptions integration guide to make a button. Any created subscription, be it via a button click or API call, starts in a created state and pending approval until some payer signs in and confirms their subscription (i.e. gives approval)
Paying for an invoice has nothing to do with subscriptions, and will not approve any subscription. There is no way for a subscription to be approved that does not involve the user signing in and approving it, via its own button or link (nothing to do with invoices).
If you want to solicit subscriptions via an "Invoice", send your own invoice message (not a PayPal invoice) and include the subscription link, or a link to your own page's invoice view with a subscription button.

Related

How to change PayPal subscription account?

I implemented PayPal subscription on my site, using PayPal smart button.
The generation of subscription plans implemented on the site via PayPal subscription API v1.
Is there a possibility to implement a "change PayPal account" button for our clients? So that a client could keep the subscription status but switch the account the payments are charged from?
The client id of the button and the client id + secret for which the product and billing plan are created must be the same.
You can reuse the API code but you must create the product and plan for each account.

How to capture only one transaction from multiple authorized transactions?

I am building a payment system where a user can make a payment against an orderId
I want to make sure that only one payment gets through (gets captured)
The payment flow is like this:
1- User clicks on Paypal button
2- a Transaction PENDING_PAYMENT gets created for the user with orderId
3- User pays in Paypal
4- Paypal sends webhook and marks the payment as AUTHORIZED
5- The system CAPTURES the payment
as you see, the user can open multiple Paypal pages and pay all of them at the same time, there's no way for me to prevent this, but I want to be able to CAPTURE only one of these payments. (so I can automatically refund the rest of the payments)
I really appreciate any help, Thank you in advance.
When you set up the PayPal transaction for approval, pass a unique invoice_id to PayPal that has never before been used for a successful payment on that PayPal account. This could be your orderId, perhaps with some additional prefix added if desired. (For instance if you had multiple storefronts on the same PayPal account that might use the same order numbers, a prefix of 3 letters and a dash indicating the store name is a typical choice)
By default, PayPal accounts prevent (block) any subsequent payments for an invoice_id that was previously used for a successful payment on that account -- precisely to prevent accidental payments for the same thing, as is your use case.

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.

Is it possible to unsubscribe an user via the Paypal Adaptive payment API?

My users subscribe to my project using the paypal button "Subscribe", and then I manage the monthly payments via the IPN, but if the user delete his account, I'd like to unsubscribe him automatically, without asking him to go to Paypal to cancel his subscription.
Is it possible to use the Paypal Adaptive Payment API to tell Paypal to unsubscribe this user ?
Bonus question : is it possible to use the Paypal Adaptive Payment API to know the status of the subscription, and eventually also to modify it (lower the amount for example) ?
You wouldn't use the Adaptive Payments API to unsubscribe a user from a subscription. If the buyer signed up for a subscription, you could ManageRecurringPaymentsProfileStatus API to cancel the profile. As for the status, you would not be able to use the "GetRecurringPaymentsProfileDetails" API call to get the status for subscriptions. This would only be supported for recurring payments, not subscriptions. However, you could use IPN which would send you the details when the profile gets created, when a new transaction is processed, and etc. Then you could just query your own database for the details.

How can I retrieve subscription profiles user have signup by item_number or invoice id

I can't find any document on PayPal page.
This is my situation,
I choose 'Cart checkout' method for my site.
Customer check out by clicking form submit button.
Customer's paid and signed-up the subscription.
Paypal sent IPN back to the server. Notify the sign-up is completed.
The server is down.
The server is up again, and can't get the IPN.
The problem is I have a link to paypal if customer has not paid it by checking transaction status. In the situation above customer can make a duplicate subscription ($100/month instead of $50/month), I just want to cancel old subscription before create a new one.