Musical Score-sheets Research

Aim

The aim of this research is to find a way to display my clients musical score-sheets on the website for people to preview and then be be able to purchase the full copy. As an added bonus it would be nice to have the music being sold in score-sheet form to be there too to playable for the user.

Payment system

x-click-but6[1]

The payment system has already been decided in my meeting with the client to be using PayPal buttons to purchase the individual score-sheets.

The only issue then becomes how do we code that so it triggers a full copy of the score-sheet to made available to the user through the website or by email.

ghazni_h_dmp_assignment3_paypal_html_variables_bitesize

So what I can gather is that HTML variables are the core of getting what I want from PayPal. I want for the user to be able to purchase a score-sheet then be directed after purchase to the full product.

ghazni_h_dmp_assignment3_paypal_dev_redirect

Now PayPal say in this developer site that each button can be individual for the product so if I redirect them after they come back from the PayPal gateway then we can direct them to the link to the full product.

The only issue with that is somebody could send the link around and other users could bypass ever having to pay for it again.

So we need something different that protects easy access to the full product but ensures the user can easily access their product again after purchase if they wish to download it more than once. An email with a temporary link could be the best solution.

After researching  PayPal developer forums I found that this type of sale comes under selling of ‘Digital Goods’ which there are a lot of third party companies (charge an average 5% per transaction) that offer to do it for you through their systems, widgets or plugins. Though the client might not agree to being charged 5% for every purchase so we’ll see if there are any alternatives first. I will try and learn to do it by myself as much I possibly can.

Using Google Mail for PayPal Digital Goods purchases

I found a guide written by  that guides you to how to simply use Google Mail to store and deliver the digital goods through PayPal. I feel this avoids having the link available to anyone through the first method we looked at by redirecting them to a particular URL.

It means they only get ONE copy of the product and if they need another copy they can always get in touch. We can then query whether they purchased it before using the PayPal payment records.

paypal-buttons[1]

I’ll have to go to my PayPal account and when creating a product assign it a unique ID. Create the PayPal button then insert the HTML code into the relevant webpage.

paypal-buy-button[1]

Then I need to insert this script in a JavaScript (.js) format obviously amending the email addresses and product ID’s.

/* PayPal Shop with Apps Script */

/* Written by Amit Agarwal – ctrlq.org */
PAYPAL = [
[“product-001”, “useful-websites-book.pdf”],
[“product-002”, “linux-training-course.mp4”],
[“product-003”, “steve-audio-book.mp3”],
[“product-004”, “presentation-template.ppt”]
];

function PayPal() {
ScriptApp.newTrigger(“myShop”).timeBased().everyMinutes(5).create();
}

function myShop() {

var file, size, files, threads;

for (var p in PAYPAL) {

threads = GmailApp.search(“is:unread from:paypal ” + PAYPAL[p][0]);

if (threads.length > 0) {

files = DriveApp.searchFiles(‘title contains “‘ + PAYPAL[p][1] + ‘”‘);

if (files.hasNext()) {

file = files.next();
size = file.getSize()/(1024*1024);

for (var i=0; i<threads.length; i++) {

var buyer = threads[i].getMessages()[0].getReplyTo();
var subject = “Thank you for your purchase”;
var body = “Please download the file using the link below.\n\n”;

if (size > 20) {
file.addViewer(buyer);
GmailApp.sendEmail(buyer, subject, body + file.getUrl());
} else {
GmailApp.sendEmail(buyer, subject, body, {attachments: file.getBlob()});
}

threads[i].markRead().moveToArchive();
}
}
}
}
}

google-drive-paypal-links[1]

Then that’s it according to the guide. The script will read the clients Gmail mailbox every 5 minutes and will process all the PayPal related emails sending the digital-goods to the user.

Displaying the Musical Score Sheet

I could either manually code into the website to display the PDF with a script like the one below:-

ghazni_h_dmp_assignment3_embedd_pdf_code

Or I could either use a third-party Java Script Utility which does a lot of the work for me.

https://github.com/pipwerks/PDFObject

I think I’ll choose manually coding it in myself to keep the project challenging.

Conclusion

I’ll be using the manual Gmail, Google Drive and PayPal to sell/deliver the digital-goods using the method above because it also protects the clients products from being available for free if the URL is passed around. It also seems an interesting project and I had no idea something as simple as that was even possible. It was a great learning experience to learn how to do that for selling digital-goods.

In terms of displaying the musical-score sheets I’ll simply embed that with HTML but if it doesn’t look quite right I’ll have to use Java Script Utilities like ‘PDFObject’.

In terms of playing the music I’ll use HTML5 audio tags as I’ve already researched that element of the score-sheets when researching into to manipulating audio hardware through code.

Resources

https://developer.paypal.com

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HH00W2J

https://www.paypal-community.com/t5/How-to-use-PayPal-Archive/I-want-to-send-automatic-products-downloads-or-PDF-after-payment/td-p/47692

http://www.labnol.org/internet/sell-digital-products-online/28554/

http://stackoverflow.com/questions/14081128/how-can-i-embed-a-pdf-viewer-in-a-web-page

https://github.com/pipwerks/PDFObject

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s