Send a link to pay via paypal

0

I am using a Google Form to record answers from different friends. Depending on their answers they are going to receive different bills. I want to create a Bash script that...

  1. Download the answers every 3 minutes
  2. Check if there are new answers in the past 3 minutes
  3. Calculate their bill
  4. Send an email with a paypal invoice.

I am having issue for the point number 4. I have a standard account on Paypal. I understand how I can use the email an invoice option to directly email an invoice. However, this solution doesn't allow me to

  • Send an invoice automatically and directly after the user has answered to the Google Form
  • Send an invoice that is a function of answers to the Google Form.

Note that it is important that I can track who paid with an ID number.

What solution do I have? For example, can I produce about 40 types of invoice corresponding to 40 different URLs and then just send the URLs on my email?

Remi.b

Posted 2015-10-12T22:49:46.113

Reputation: 2 431

Answers

1

This solution isn't PayPal, but I think it's worth to share.

You may use FreeAgent API where you can create an invoice via curl, for example:

curl https://api.sandbox.freeagent.com/v2/invoices \
 -H "Authorization: Bearer XXXXXXX" \
 -H "Accept: application/xml" \
 -H "Content-Type: application/json" \
 -X POST  \
 -d '{
    "invoice": {
        "contact": "https://api.sandbox.freeagent.com/v2/contacts/1",
        "status": "Draft",
        "dated_on": "2012-08-16",
        "currency": "GBP",
        "exchange_rate": "1.0",
        "comments": "Added by api",
        "omit_header": false,
        "payment_terms_in_days": 30,
        "invoice_items": [
            {
                "description": "Test InvoiceItem",
                "item_type": "Hours",
                "price": "112.0",
                "quantity": "1.0"
            }
        ]
    }
}'

Code source: Create Invoice through API - PHP cURL - Sandbox

kenorb

Posted 2015-10-12T22:49:46.113

Reputation: 16 795

1

This example creates an invoice using CreateInvoice via PayPal Invoicing API:

curl -s --insecure
-H "X-PAYPAL-SECURITY-USERID: Your_API_username"
-H "X-PAYPAL-SECURITY-PASSWORD: Your_API_password"
-H "X-PAYPAL-SECURITY-SIGNATURE: Your_API_signature"
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
-H "X-PAYPAL-APPLICATION-ID: Your_AppID" https://svcs.sandbox.paypal.com/Invoice/CreateInvoice
-d
"requestEnvelope.errorLanguage=en_US
&invoice.merchantEmail=merchant%40domain.com
&invoice.payerEmail=jbui-us-business2%40paypal.com
&invoice.currencyCode=USD
&invoice.itemList.item(0).name=Banana+Leaf+--+001
&invoice.itemList.item(0).description=Banana+Leaf
&invoice.itemList.item(0).quantity=1
&invoice.itemList.item(0).unitPrice=1
&invoice.itemList.item(0).taxName=Tax1
&invoice.itemList.item(0).taxRate=10.25
&invoice.paymentTerms=Net10
&invoice.logoUrl=https%3A%2F%2Fwww.example.com%2FYour_logo.jpg"

This one, would send it (SendInvoice):

curl -s --insecure
-H "X-PAYPAL-SECURITY-USERID: Your_API_username"
-H "X-PAYPAL-SECURITY-PASSWORD: Your_API_password"
-H "X-PAYPAL-SECURITY-SIGNATURE: Your_API_signature"
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
-H "X-PAYPAL-APPLICATION-ID: Your_AppID" https://svcs.sandbox.paypal.com/Invoice/SendInvoice
-d
"requestEnvelope.errorLanguage=en_US
&invoiceID=INV2-RVY9-UWTW-64HZ-BR9W"

To create and send at the same time, use CreateAndSendInvoice:

curl -s --insecure
-H "X-PAYPAL-SECURITY-USERID: Your_API_username"
-H "X-PAYPAL-SECURITY-PASSWORD: Your_API_password"
-H "X-PAYPAL-SECURITY-SIGNATURE: Your_API_signature"
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
-H "X-PAYPAL-APPLICATION-ID: Your_AppID" https://svcs.sandbox.paypal.com/Invoice/CreateAndSendInvoice
-d
"requestEnvelope.errorLanguage=en_US
&invoice.merchantEmail=merchant%40domain.com
&invoice.payerEmail=jbui-us-business2%40paypal.com
&invoice.currencyCode=USD
&invoice.itemList.item(0).name=Banana+Leaf+--+001
&invoice.itemList.item(0).description=Banana+Leaf
&invoice.itemList.item(0).quantity=1
&invoice.itemList.item(0).unitPrice=1
&invoice.itemList.item(0).taxName=Tax1
&invoice.itemList.item(0).taxRate=10.25
&invoice.paymentTerms=Net10
&invoice.logoUrl=https%3A%2F%2Fwww.example.com%2FYour_logo.jpg"

kenorb

Posted 2015-10-12T22:49:46.113

Reputation: 16 795