Updating Paypal after authorization

Posted on 2010-09-16
Last Modified: 2013-12-12
Okay, so I'm not sure this is possible but I thought I'd ask.

We're using Paypal Payments Pro (with PHP code), so this is all with using paypal as a merchant account via CURL -- not redirecting the customer.

In our order system, I have two sets of numbers, one is a OrderID which is a primary key and sequential. Orders can be created and sometimes deleted if a person decides not to complete the order. The second number is the InvoiceID which is only generated once payment is actually successful, in order not to generate gaps in numbers or voids. Once a payment is done, I find the MAX(InvoiceID), add 1 and update the Order record.

The problem is with Paypal. I'd like to put the Invoice number as part of the Description since our accounting dept looks at that. But it's circular logic -- I don't have the Invoice number until the Paypal transaction is successful, and once I have it, Paypal is done. So is there a way to go back to Paypal and update that description (or any field) after the fact?
Question by:ktwdallas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Accepted Solution

neeraj523 earned 500 total points
ID: 33699750
In first shot, i can say paypal dosnt provide any such facility to update the already posted order details..

I will suggest to create the invoice before sending payment request to paypal and send invoiceid to paypal.. But you maintain additional field in invoice table such is IsPaid with yes/no option.. First time when you add invoice, keep it as IsPaid=No and once get payment confirmation from Paypal, update this record with status Yes.

LVL 110

Expert Comment

by:Ray Paseur
ID: 33700128
Wow, this sounds scary.  Did you find something in the PayPal Developer documentation references that guided you to this design pattern?  If so, let's call it out right now.

If the programming needs the OrderID to be the primary key, sequential and without gaps, it is not a technically competent design.  This is a way to be certain that disaster is not left to chance.  It is axiomatic that data base keys have no external meaning - they are present in the data base tables to implement the relational nature of data bases, but nothing else.  The world is littered with the dessicated husks of applications that tried to have "meaningful keys."  So please don't do that.

I suggest that you keep separate columns in your own tables for after-the-fact data assignments.  And educate your accounting department about the meaning of a "description" -- it is there to tell the client about the product, not to give the accounting department an order sequence number.  The sequence of orders and invoices will always be available from the DATETIME fields of the PayPal transaction records.  The PayPal-assigned order identification numbers will be there, too.  These are the fields you should depend on.


Author Comment

ID: 33701492
Ray, you misunderstood. The OrderID is the primary key, but there are no requirements there. What I was saying was that records could be deleted (because orders are abandoned before they're paid for and just through maintenance, we drop those rows). So there are missing OrderIDs, that doesn't matter.

There is a second field, a simple int field, which is NULL until we assign an InvoiceID to it upon payment for an order. That's where we can't be missing numbers. So our table might be something like below. We're missing OrderIDs from deleted records, but who cares. Only successfully paid records are assigned an InvoiceID (again, upon completion, by finding the last used and incrementing one).

I could assign an invoiceID the moment I bill, but if it's a decline and they never come back, then I have an outstanding Invoice the customer never intends to pay, which we have to show as Void and you don't want to have tons of voided Invoices on your books.

(Obviously our real table has many more field.) The Description also goes to the customer on their Paypal screen (which is the real reason I wanted it there). Yes I could just switch to the Order number, which is what will be done since neeraj523 answered the question I was asking.

OrderID		InvoiceID		CustomerName		TransactionResult
100			NULL			Bob
104			9000			Julie				X238DAG293AS3
105			NULL			Tom
107			9001			Bill				E493839D93840
110			9002			Mary				UD338374DJGH3

Open in new window


Author Closing Comment

ID: 33701509
The simple "no" was what I was looking for. Thanks.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question