Create a PayPal invoice, mark paid and send email - paypal

Using the PayPal API, I want to send an invoice marked as paid via email, as soon as the buyer completes the purchase in the web application.
Is it possible?
Without using the API, you cannot send an email notification manually for paid invoices. Is that right?

In your checkout system, when the order comes through, make a call to the CreateInvoice API. This will generate the invoice in the PayPal system. You can use the "number" parameter in the CreateInvoice request to pass your regular order ID if you have one so that the invoices are nicely related to your checkout order.
Then, immediately after that call, make a call to MarkInvoiceAsPaid. This will mark the invoice as paid in the PayPal system so that you have a nice record of it there.
Sounds like what you're after, right?
If you happen to be working with PHP, my class library for PayPal will make all of the invoicing API calls very simple for you.

You need to do 3 things:
CreateInvoice
SendInvoice (then customer receives invoice via e-mail, but he still button "Pay now").
When he pays you directly, you send MarkInvoiceAsPaid. That removes the "Pay now" and adds message that the invoice is marked as paid on the given date.

You need to make 3 API calls here:
Create an invoice
Send invoice
Record payment
When you create an invoice, it is created in DRAFT state and it is actually not a legitimate invoice. So, when merchant send this invoice the state of the invoice changes to SENT state and it becomes legitimate. To mark it as paid, you need to call record payment API and pass the payment method in request body as CASH, CREDIT_CARD, DEBIT_CARD, PAYPAL, WIRE_TRANSFER or, OTHER. The API documentation on PayPal developer site is pretty much informative. I hope this answers your question.

Related

Integrating Paypal Payment and Invoicing APIs

I have been manually issuing invoices to charge my clients for services using Paypal.
Now I am creating an interface to allow them to purchase the services automatically on my website.
I also want to show them a history of their purchases. However, I cannot show a history of paid invoices using the Transaction Search API; I need to use the Invoicing > Search Invoices API.
I have used the Paypal Payments API to manage the payment side of new products, which now correctly produces an itemised transaction and allows the customer to checkout. But this does not produce an invoice.
How can I simultaneously produce an invoice (i.e which can be retrieved by the Invoicing API to show previous payments) and allow the customer to pay it? It seems like the Invoicing API works around the idea of sending an invoice to client by email, but this is unnecessary. I want them to pay it immediately (and already have the Payment API setup for this).
So what would a useful workflow be?: Use my Paypal Payment API to receive and authorise the payment, and on authorisation, use the Invoicing API to produce an invoice which reflects this and then updates the invoice status to paid? Or am I missing something easier here?
The Invoicing API is not meant to be mixed or used with any other API. It is for generating invoices to be sent by email or in link form.
General ecommerce payment processing (without invoice links) is entirely separate, there is no crossover. You should ensure you are using the current v2/checkout/orders API to receive new payments, not older v1 APIs.
As far as displaying a list of previous purchases to your customers, you shouldn't reply on PayPal for this (except perhaps in the case of invoices since this is part of the point of offloading invoice management to PayPal). But for normal web purchases, PayPal is not a database -- it is a payment processing service. Keep track of all your own order information, and simply store PayPal transaction IDs when they complete for your own accounting records -- but the ID you reference with the customer should be your own unique order ID, which you can pass to PayPal in your purchase_units[0].invoice_id when you create an order for checkout approval.

PayPal - Pass Customer ID from my website - Receive confirmation with same Customer ID from my website

I am working on a software service and am offering a monthly subscription for my software service.
I am currently working on the subscription part - and am wanting to implement a paypal monthly recurring payment solution.
I have spent quite a bit of time looking over PayPal documentation, and trying different buttons, webhooks, IPN methods etc.
The problem is that I am not sure what solution to use - because I am confused by the multiple options.
What is most important to me is - that when the customers fill out the form on my website - and are then directed PayPal to pay - I then want to know that specific Customer ID from my website has successfully paid.
I would like to know:
Which SPECIFIC option(s) PayPal has that I can pass Customer ID from my website of that customer - let's say a subscription ID from my site - and that PayPal will then send the customer back with my subscription ID, that I passed them on to PayPal with.
Which is the easiest option to do that with?
I simply want the customer to:
sign up at my site. (my part)
be issued a unique Customer ID from my website (my part)
click a PayPal payment/subscribe button (my part)
be sent to PayPal to pay for the subscription (paypal's part)
be returned to my site with the unique Customer ID from my website from my site - as well as a confirmation of payment from PayPal (paypal's part)
Please do not simply pass me to the general area of the development sections -
As I said - I have already been through all of that and find there is too much information.
Please direct me to a specific solution, or example, or tutorial that covers a solution that will fit what I need.
I would recommend using the Express Checkout API with Recurring Payments.
The best thing to do would be to create a local invoice record in your system, and then have a related customer ID associated with that invoice.
In the CreateRecurringPaymentsProfile request to PayPal you can include a PROFILEREFERENCE parameter, which would be the invoice ID you generated for that order in your system. Then all future payments related to that profile would include this same reference ID as part of its data, so if you're using IPN, for example, it would be included there.
When working with Express Checkout the user is always guaranteed to end up back on your site to finish the checkout flow, so you can simply save data in sessions during checkout and update things like your database, email receipts, etc. directly in your payment flow. Then you could use IPN to process the recurring payments after that, and again, it would include that same reference ID. In IPN this would come back as rp_invoice_id.

Relation between payment made with createbutton api and ipn message

Our customers sends their requests for our products via email. Their requests are saved in our database and after we check their requests, we want to send them an email which contains the paypal payment link. To execute this, I am using BMCreateButton method of ButtonManager API of Paypal.
https://developer.paypal.com/docs/classic/api/button-manager/BMCreateButton_API_Operation_NVP/
This method returns EMAILLINK parameter and I am using this parameter in the email to redirect to user to paypal payment page. This method also returns HOSTEDBUTTONID and I am saving this parameter and EMAILLINK parameter to the database to make a relation between the email link(hostedbuttonid) and the user request.
For the payment notifications, I think my only choice is IPN of Paypal. I developed a page to handle the IPN messages from paypal and it works fine but the problem arises when I want to relate between the payment information with the email link that was sent to the customer. I mean I want to know for which request this payment was made. IPN message does not return any information about the HOSTEDBUTTONID. It returns btn_id(different than the HOSTEDBUTTONID), txn_id and ipn_track_id but none of them is useful to relate the customer request( or email sent) with the payment.
Do you have any suggestion about my issue? Or do you think I should use another way for sending the payment email to the user instead of BMCreateButton method of ButtonManager API.
In the BMCreateButton call, where you're setting up the standard PayPal variables for the button, add the CUSTOM parameter. Within that you can pass any value you want (up to 256 char.) and then that same value will come back in the IPN so you can relate it accordingly.
If you have a specific Order ID you could use the INVOICE field instead, and that would come back in IPN as well.

Paypal request money - does it have API?

There is a request money by email feature on paypal - (where you can put email of some person and he can send you money)
Does it have an API ? (So I want to request money by email from my application)
So the answer is - no such API
It looks like you can send invoices (request money) by email with the Invoicing Service API
You can create your own personal PayPal.Me/name link (it's open to both personal and business use) and it will be associated with your PayPal account.
Whenever you need to collect money from anyone, just send them your PayPal.Me link via email (or chat, SMS...).
Your payer clicks the link, enters the amount, and that's it. The money is in your PayPal account in seconds (you'll pay the standard PayPal fee for a business account).
To request a specific amount just add it to the end of your link. For example, use
PayPal.Me/name/25
to request 25 USD. You can request a specific currency by adding the currency code to the amount, e.g.
PayPal.Me/name/25EUR
IT has that facility. you have to generate url. its mentioned at
https://www.x.com/developers/community/blogs/ppmtschad/creating-hyperlink-instead-paypal-button
First method is to use the Invoice API to generate the request and have paypal send out the email.
See https://www.paypal.com/cgi-bin/webscr?cmd=xpt/Merchant/bizui/IntegrationDirect-outside
Second method is to use the buy now buttons. First create the product in the paypal account, then create a buy now button for it. It'll give an option for Email. You can then send that link out whenever you want.
See https://www.x.com/developers/community/blogs/ppmtschad/creating-hyperlink-instead-paypal-button and
Third option is the rarely advertised custom cart URL. I don't have anything that details this however the following sample link can get you started.
https://secure.paypal.com/xclick/business=EMAIL%40DOMAIN.COM&item_name=Cart_Invoice_Custom_Name&amount=123.45&return=www.yourwebsite.com&currency_code=EUR
Remember to properly URL encode things. All the variables for dynamic buttons that I've tried work fine. Details of those are at https://www.paypal.com/cgi-bin/webscr?cmd=_pdn_xclick_techview_outside

How do you connect a Paypal IPN confirmation to a user?

I wanted to use Paypal's IPN service to verify payments for a recurring subscription charge for my website. How do you tie the IPN confirmations to a user in your site?
The IPN confirmation message has a name, email, paypal ID, recurring payment ID, but it seems to not give a unique identifier since I don't know where the paypal ID or recurring payment id comes from and it may not be trivial to uniquely match up the name/email that a user has on their paypal account (or entered there) with the name/email I have for them on my site (there may be many John Smith's and the person may choose to use a different email.)
1) When I send the initial payment request to Paypal, I can attach a unique UUID in the URL I ask them to send back to me, so if I save that unique ID for that user I can match that payment confirmation to the user who initiated it. Am I making that harder than it is? Is there an easier way?
2) Also, for a recurring/subscription charge, does paypal always use the URL I specified with the initial payment initiation? Does anyone have practical experience using the recurring Paypal payments with IPN's, does it reuse that unique URL? Or do I have to associate the Paypal ID's with the user after the first recurring payment is received?
Attaching unique data to the payment request is pretty much the accepted way to do it.
I don't have any experience with recurring charges.
I recently also set up some reoccurring payments with Paypal.
I actually wanted people to register as members after paying for the subscription, if they wanted to. As having to sign up as a member could add some friction to the sale process. So I don't send any user info along with the Subscribe button.
What my IPN script does is generate a unique activation code tied to the Paypal subscriptionID in the Activations table, then it sends this code to whoever paid for the subscription, with instructions on how to activate.
At the point of activation, you need to register or login. At this point the userID is added to the relevant row in the Activations table.
When the EndOfTerm IPN notification comes in the IPN script looks up the userID from the Activations table based on the SubscriberID given in the IPN. Then I can do whatever I need to do to that user to disable their subscription.
At all time the URL of the IPN script remains the same.
1) You can send an 'item_number' parameter with the initial subscription setup, which will get passed back to you. I'd suggest embedding an identification token in it.
2) If you mean the 'return' parameter, no, that's for sending the user to at the conclusion of the subscription setup. The renewal is automatic and doesn't 'ping' that page.
1) You want to be using the item_number parameter. Set this in your HTML form shown to the customer, and it will be returned to you by the paypal IPN, so you can put a database row ID in here, and use it to match up to the right person later.