Skip to content

Instantly share code, notes, and snippets.

@mfifth
mfifth / app.js
Last active September 21, 2017 17:04
var shopify = new shopifyAPI({
shop: 'kauai-project.myshopify.com', // MYSHOP.myshopify.com
shopify_api_key: 'xxxxxxxx', // Your API key
shopify_shared_secret: 'xxxxxxxxxx', // Your Shared Secret
shopify_scope: 'read_orders, write_orders, read_customers, write_customers, read_products',
redirect_uri: 'http://localhost:3000/dashboard',
});
async function send_to_shopify(billing_data) {
console.log(billing_data)
async function save_account(ctx) {
const {files, fields} = await asyncBusboy(ctx.req);
var email = fields.email;
var first_name = fields.firstName;
var last_name = fields.lastName;
var address = fields.address;
var addressTwo = fields.addressTwo;
var city = fields.addressCity;
var state = fields.addressState;
var zip = fields.addressZip;
@mfifth
mfifth / koa.js
Created September 18, 2017 18:40
const Koa = require('koa');
const Router = require('koa-router');
const app = new Koa();
const router = new Router();
let users = [
{
name: "Jacob",
email: "[email protected]",
"{\"order\":{\"id\":58505297944,\"email\":\"[email protected]\",\"closed_at\":null,\"created_at\":\"2017-08-31T18:29:04-05:00\",\"updated_at\":\"2017-08-31T18:29:04-05:00\",\"number\":292,\"note\":\" | Subscription ID: 18906020 | Shopify ID: 83820085272 | Product SKU: SW-FS-BB-DT-12 | Product Handle: fastscout-desktop-1-year\",\"token\":\"91df2a5a7d0772ab8a9df574538d7999\",\"gateway\":\"\",\"test\":false,\"total_price\":\"74.99\",\"subtotal_price\":\"74.99\",\"total_weight\":null,\"total_tax\":\"0.00\",\"taxes_included\":false,\"currency\":\"USD\",\"financial_status\":\"paid\",\"confirmed\":true,\"total_discounts\":\"0.00\",\"total_line_items_price\":\"74.99\",\"cart_token\":null,\"buyer_accepts_marketing\":false,\"name\":\"#1292\",\"referring_site\":null,\"landing_site\":null,\"cancelled_at\":null,\"cancel_reason\":null,\"total_price_usd\":\"74.99\",\"checkout_token\":null,\"reference\":null,\"user_id\":null,\"location_id\":null,\"source_identifier\":null,\"source_url\":null,\"processed_at\":\"2017-08-31T18
def self.send_order(order, shopify_signature)
shop = Shop.first
headers = {
"X-Shopify-Topic" => "orders/paid",
"X-Shopify-Hmac-Sha256" => shopify_signature,
"X-Shopify-Shop-Domain" => shop.shopify_domain,
"X-Shopify-Order-Id" => order.id,
"X-Request-Id" => 'some-value',
'Content-Type' => 'application/json',
'Accept' => 'application/json'
#<HTTParty::Response:0x7fffdbcc0bb8 parsed_response={"errors"=>{"base"=>["either refund line items or transactions must be present"]}}
$('.my-div').on('scroll', function() {
if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
console.log("You have reached the bottom!");
}
});
<div class='category-list'>
<h1 style='text-align: center; color: blue;'>Categories</h1>
<ul style='list-style: none!important; padding: 0px; margin-top: 40px!important;'>
<% categories.each do |category| %>
<li style='margin-bottom: 10px;'>
<p style='display: inline; margin: 0px;'>
<%= link_to category.name, "https://myapp.herokuapp.com/categories/supplements/#{category.id}", style: "color: blue;", data: {id: category.id, class: category.class.name}, class: "view-files-link ajax-nav" %>
- <%= category.supplements.count %> Files
</p>
<% if SubCategory.where(category_id: category.id).empty? %>
$(document).on("submit", ".resource-form", function(e) {
$.ajax({
url: $(".resource-form").attr("action"),
type: "POST",
crossDomain: true,
dataType: "html",
data: $(".resource-form").serialize(),
success: function(data) {
$(".rails-app").html(data)
},
class AppProxyController < ApplicationController
include ShopifyApp::AppProxyVerification
protect_from_forgery :except => [:check_password]
after_action :set_headers, only: [:check_password]
def index
render layout: false, content_type: 'application/liquid'
end
def login_form