Does the PayPal API allow you to assign a price based on an algorithm? If so, how? - api

I have been reviewing this forum and the documentation for PayPal API but am still uncertain about one thing: Can I have an algorithm determine the price of certain services on a PayPal button (rather than designing a bunch of preset buttons and choosing which one to display)? I would like to have this information feed in from an external database and would appreciate any tips on which lever to pull.
Thank you!

You would have to make sure it's not a hosted button, which would make the amount be included in a hidden field with the form button. Then you could dynamically adjust the amount based on any logic you want.
The down-side to that is the button isn't as secure because people could view source, copy the HTML, change the amount, and then submit the payment that way. Of course, there are ways to manage this, but it's something to consider.
Another option would be to use the Express Checkout API instead, in which case it would be completely secure and fully customizable to handle pricing however you need to.

Related

Saving additional data when checkout is completed on shopify

I'm not entirely sure how to go about this so i thought i'd ask here.
Context
I have a quiz that people take on my site and when the quiz is completed, a product is recommended based on their quiz results. A customer is now able to buy this recommended product.
What i want to do is to be able to save the quiz response to my external database with the order id as a unique id for quick retrieval later. How would i go about this in Shopify?
Question
Is there a way i can make a POST request when the checkout button is pressed on the checkout page?
Would i have to create a custom checkout to get access to that area?
Thank you
If you're attempting to save to an external database then you'll need to figure out a way to send data from your Shopify frontend to an external app or API, one that will capture the product data and add it to the DB.
To answer your first question, no, you can not hijack the functionality of the checkout button (unless you do so via Javascript).
As for your second question, I don't know what you mean by 'custom checkout' but I'd say you're probably looking in the wrong area for the solution to this.
Shopify's backend is not able to be edited by the merchant themselves and can only be accessed via its various APIs.
How I would do it if I were you is to create that external app, create an endpoint that accepts the product data / adds to the DB and write code on your Shopify front-end to send the data to that endpoint.
Keep in mind that you won't be able to easily identify the customer to whom the product is recommended to unless they are logged in.

How to add a custom section / page with an embedded app in Shopify?

For a client i want to integrate a new way of renting products in Shopify which they pick right up after ordering from a pickup point. This new way is a service which can be interacted with via an API. After ordering, a code is provided which can be used to open a locker somewhere. In the shop, on a custom page or some sort of reusable block i want have a custom HTML form which can interact with this API. The customer can then choose the product, the available pickup-point, pay for his/her order and receive the code for pickup. Is this possible?
I have done research but could not find this type of customizing.
I have built some test-apps but it seems these can only be embedded in the admin and not in the storefront itself (please correct me if i am wrong). I can interact with the storefront-api so that's a plus allright.
The ideal way would be for me to develop a React/Vue app which can be added to a page for walking trough this process described above.
Anyway, is it possible one way or another?
Thanks in advance for thinking with me on this one!

Shopify App Necessary? Hard-code into Theme?

I have much experience developing for WordPress but this will be my first project developing for Shopify.
I will be customizing a 3rd-party Shopify Theme with custom functionality as per the client's website needs. I've been reading much documentation but I am still a bit confused about Shopify Apps...
My question is:
Do I need to build an App to extend the functionality of my theme, or can I just hard-code the new functionality directly into the theme? Is there any reason to develop an App for functionality that will only be used on my theme?
I thank you very much for your advice.
Do I need to build an App to extend the functionality of my theme, or can I just hard-code the new functionality directly into the theme?
Short answer: Yes. (Damn that mathematician's response!)
Is there any reason to develop an App for functionality that will only be used on my theme?
Longer answer: Sometimes, yes.
That wasn't very helpful
Longest answer: True. Let's break it down a little more, then.
Without knowing what you need to do, I can't offer a concrete yes-or-no answer to the question, "Should I build Feature X as an app?"
If you...
Need to add, modify or delete any objects that require admin privileges (including products, variants, collections, orders, etc.), or...
Need to listen for any of Shopify's webhooks, or...
Need to store data in an external database for any reason...
... you will need an app to have the permissions required to access and manipulate data at this level.
However, if you...
Can do everything you need with the existing Shopify objects, and...
Need few or no settings to control the desired behaviour...
... you would not need to create an app. Shopify themes have some powerful tricks & tools available to you, including:
The ability to create custom endpoints for any of the main types of objects to get the data you need;
Easily-edited settings_schema file to add arbitrary configuration variables to help control your mini-app;
Javascript endpoints to let you add, remove & edit products in the cart
Hopefully this quick breakdown helps you decide if you need to create an app or not. (And to anyone who does need to make a single-site app, remember that Shopify lets you create 'Private Apps' that don't have to go through the app store process to get widespread approval)
I thank you very much for your advice.
You're welcome! Hopefully it proves to be helpful. Good luck!

Looking for a way to subscribe to events within my Shopify store

I work with some third party referral systems and I've been looking for a way to trigger some JS off of events like Add To Cart, Add Coupon to Order, and Checkout. I'd like to be able to do this without having to use the id of the button in question as these can change from theme to theme, and become complicated when you're dealing with multiple buttons for the same functionality.
It seems like the built in Google Analytics and Facebook Tracking are using some sort of event system to trigger their data collection, but I can't seem to find anything in the docs or forums explaining how this works or how I can use it without using their services. Ideally I'm looking for some kind of liquid if/then sort of structure or alternatively just a clear event of some kind that I can listen for.
Obviously I could use jquery to accomplish this by listening for different button clicks but that seems like a really brittle way of handling something that is clearly part of the core of how Shopify works.
Any thoughts or suggestions would be really appreciated (At this point I'll name my first born rumplestiltskin)
(Repost from here https://ecommerce.shopify.com/users/554977/posts)
You can subscribe to webhook events through the API:
https://help.shopify.com/api/reference/webhook
There are topics for carts/create and checkouts/create which you might find useful. For coupon codes, you can subscribe to orders/create webhooks and parse the order data to see if it contains a coupon code.
Do what everyone does, including GA and other trackers. Build an App that installs in shops, and that App uses the API to inject JS that triggers onload. You can then program the JS to callback your mothership with the data you are interested in.
Note that your approach of asking for a trigger is far too vague to ever work. Why re-invent the wheel or beat a dead horse. Free up your valuable time and just go with the flow.
https://help.shopify.com/api/reference/scripttag

Easy script to sell and generate unique passwords to a protected area?

Here is what I'm trying to accomplish:
Three different products-- each one consists of online content, housed within a unique folder.
The customer purchases one of the three products, and receives a username/password (or it could be some sort of dynamic link that expires) for that product.
I am not a programmer, but I know enough to get myself in trouble. I thought I could find a simple script where I would just have to change a couple of parameters and be good to go. Surely this has been done before, right?
I need something that will somehow send the info to a payment processor (PayPal is preferable, but Google Checkout could be an option too), generate a unique password or code and email it to the buyer, and of course communicate to the folder where the product lives so that the password/code will work.
Am I crazy? Is this something that I need advanced development skills to pull off? I have been looking at open-source shopping carts to see if one of them has this functionality built in, but haven't been able to find anything.
There is a PayPal script that is supposed to do this, but I have tried working with it before and it is a real pain...I'm not even sure ultimately that it will work the way I want it too.
Any suggestions are most welcome!
From your description it looks like you are trying to sell digital content.
Both Google Checkout and Paypal have frameworks in place that allow you to securely sell and deliver digital goods.
Please have a look at the doc below for Google Checkout Digital Delivery:
http://code.google.com/apis/checkout/developer/Google_Checkout_Digital_Delivery.html