CloudHow to automatically send PayPal transactions to Google Sheet

How to automatically send PayPal transactions to Google Sheet

Google Sheet setup

Google Sheets is a free spreadsheet offered by Google. For those familiar with Excel will find Google Sheets no different. You will need a Google account to create a Google Sheet. Create an account if you don’t have one.

After opening the sheet, write a few lines of code that will be called from your PayPal account to send the transaction when an activity happens in PayPal. The code will get transaction information and write into the sheet.

How to write the code

After opening the Sheets change the name from Untitled spreadsheet to something relevant. Then click Script editor from Tools menu

Writing the code

Clear the template block of code and replace with the code below.

function doPost(e) {

  var rowData = [];

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet()

  rowData.push(new Date(e.parameter.payment_date));
  rowData.push(e.parameter.item_number);
  rowData.push(e.parameter.option_selection1);
  rowData.push(e.parameter.payment_status);
  rowData.push(e.parameter.payment_gross);
  rowData.push(e.parameter.mc_currency);
  rowData.push(e.parameter.payment_fee);
  rowData.push(e.parameter.first_name);
  rowData.push(e.parameter.last_name);
  rowData.push(e.parameter.payer_email);
  rowData.push(e.parameter.residence_country);
  rowData.push(e.parameter.txn_id);
  
  sheet.appendRow(rowData);
}

That’s all the code. For the technical folks, PayPal sends an event (e) to Google Sheets with ‘parameter’ that contains all the transaction data. Explore PayPal developer section for more details.

Deploy code to web

Select Deploy as web app in Publish menu. This is important step, make all changes carefully here. Any error will result in failed link with PayPal.

You will be prompted through series of verification steps to complete Google permissions. Start by completing the options on first screen and click Deploy button. Give permission to owner of Google Sheet.

  • In Project version: select ‘new’, enter description
  • Execute the app as: Me
  • Who has access to the app: Anyone, even anonymous

After completing all verification, a screen like below will pop up. Copy the URL carefully into notepad. You will need it during Instant Payment Notification (IPN) setup in PayPal.

Home | Google Sheet Setup | PayPal Setup | Test IPN

Email acloudpage@gmail.com to get professional help and get started.

Pages: 1 2 3 4

Categories: Cloud Tags: , , , ,