Skip to content

Instantly share code, notes, and snippets.

module ErrorReporter
extend Forwardable
@name = 'ErrorReporter Class Instance Variable'
def self.api_client
@sl_api_client ||= SlApi.api_client
end
api_client.public_methods(false).each do |method|
$scope.loadItems = function() {
$scope.loadingItems = true;
$http({
method: "GET",
url: '/api/admin/v1/'+mainConfig.merchantId+'/users/settings',
}).success(function(data,status) {
$scope.setting = data;
$http({
method: 'GET',
url: '/api/admin/v1/'+mainConfig.merchantId+'/users/'+$scope.recordId,
require 'rails_helper'
describe Api::OrdersController, type: :controller do
Given(:checkout_params) do
{
order: {
billing_address: [],
coupons: [],
custom_fields_translations: [],
customer_email: 'wtf@shoplineapp.com',
module Api
class OrdersController < ApiController
include AllpayHelper
include AsiapayHelper
include UsersHelper,CartsHelper, OrdersHelper
include EsunHelper
include PaypalExpressHelper
before_action :set_order, only:[:payment_ack, :after_receive_payment, :after_create_allpay_order, :after_create_esun_payment,:linepay_confirm,:paypal_express_return,:asiapay_return, :shop_com]
@noel9999
noel9999 / checkout.rb
Created April 7, 2017 07:07
refactor & test demo
def checkout
m = @merchant_data
seller_id = m["_id"]
unfulfillable_items = get_invalid_cart_items
if unfulfillable_items.present?
render status: :unprocessable_entity, json: { message: I18n.t('orders.error.fulfillment_error'), data: unfulfillable_items}
return
end
delivery_option_id = params.fetchpath("order/delivery_option/_id")
@noel9999
noel9999 / checkout.rb
Created April 7, 2017 07:07
refactor & test demo
def checkout
m = @merchant_data
seller_id = m["_id"]
unfulfillable_items = get_invalid_cart_items
if unfulfillable_items.present?
render status: :unprocessable_entity, json: { message: I18n.t('orders.error.fulfillment_error'), data: unfulfillable_items}
return
end
delivery_option_id = params.fetchpath("order/delivery_option/_id")
@noel9999
noel9999 / gist:45c081f96c308f65c11e
Last active August 29, 2015 14:13
js regExp 練習
var text = 'there are a lot of great websites like www.missingmanuals.com and http://www.noelsaga.com'
var urlRegex = /((\bhttps?:\/\/)|(\bwww\.))\S*/g
var url = text.match(urlRegex)
console.log(url[0])
console.log(url[1]);
//看看兩者的差異
var text2 = 'my website is www.noelsaga.com'
var urlRegex2 = /((\bhttps?:\/\/)|(\bwww\.))\S*/
@noel9999
noel9999 / gist:ee70493606edee7d0520
Created September 21, 2014 08:51
Chrome載入jquery
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementByTagName('head')[0].appendChild(jq);
//Done! Really simple as you imagine!
@noel9999
noel9999 / gist:b200847503fe5879c48d
Last active August 29, 2015 14:05
The onbeforeunload way with turbolinks.
// Without turbolinks, it works fine!
$(document).ready(function(){
formmodified=0;
$('form *').change(function(){
formmodified=1;
});
window.onbeforeunload = confirmExit;
function confirmExit() {
if (formmodified == 1) {
return "資料有做修改,確定直接離開頁面嗎?";
@noel9999
noel9999 / gist:c53cae062974c44d897c
Created July 11, 2014 10:45
Javascript: 練習實作select,模仿ruby的select
Array.prototype.select = function(callback){
count = this.length;
results = new Array();
for(i=0;i<count;i++){
if(callback(this[i]))
results.push(this[i]);
}
return results;
};