Skip to content

Instantly share code, notes, and snippets.

View vernondegoede's full-sized avatar
:shipit:

Vernon de Goede vernondegoede

:shipit:
View GitHub Profile
@vernondegoede
vernondegoede / payment_decorator.rb
Created March 20, 2018 12:01
Create a Mollie transaction, even when the order is completed (but not paid for).
Spree::Payment.class_eval do
delegate :transaction_id, to: :source
def build_source
return unless new_record?
if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
self.source = payment_method.payment_source_class.new(source_attributes)
source.payment_method_id = payment_method.id
source.user_id = order.user_id if order
@vernondegoede
vernondegoede / checkout_controller_decorator.rb
Created March 20, 2018 10:41
Redirect to Mollie checkout
module Spree
module CheckoutWithMollie
def update
if payment_params_valid? && paying_with_mollie?
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
payment = @order.payments.last
payment.process!
mollie_payment_url = payment.payment_source.payment_url
MollieLogger.debug("For order #{@order.number} redirect user to payment URL: #{mollie_payment_url}")
@vernondegoede
vernondegoede / processing_decorator.rb
Created March 20, 2018 10:37
Create a new Mollie payment
Spree::Payment::Processing.module_eval do
def process!(amount = nil)
amount ||= money.money.cents
started_processing!
response = payment_method.create_transaction(
amount,
source,
gateway_options
)
handle_response(response, :pend, :failure)
@vernondegoede
vernondegoede / trace
Created February 13, 2018 17:36
Full stack trace
mollie-api-ruby (3.1.2) lib/mollie/client.rb:28:in `instance'
mollie-api-ruby (3.1.2) lib/mollie/client.rb:36:in `ensure in with_api_key'
mollie-api-ruby (3.1.2) lib/mollie/client.rb:37:in `with_api_key'
app/models/spree/gateway/mollie_payments.rb:19:in `available_payment_methods'
app/views/spree/checkout/payment/_molliepayments.html.erb:1:in `_c1a28389e1fabe876b095bd91e2beecc'
actionview (5.1.4) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.4) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.4) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.4) lib/action_view/template.rb:155:in `render'
deface (1.3.0) lib/deface/action_view_extensions.rb:41:in `render'
@vernondegoede
vernondegoede / Gemfile.lock
Last active February 13, 2018 17:12
Gemfile
GIT
remote: git@github.com:spree/spree_auth_devise.git
revision: 541db70aeccf3de38eb7b7c8771e949fbfacdd99
specs:
spree_auth_devise (3.3.3)
devise (~> 4.4.0)
devise-encryptable (= 0.2.0)
spree_core (>= 3.1.0, < 4.0)
spree_extension
server {
listen 80;
server_name domain.com
root /data/<path_to_wp>/web;
index index.php index.html index.htm;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
@vernondegoede
vernondegoede / index.js
Last active July 30, 2017 20:50
Run in developer tools
let currentValue = 2;
let maxIterator = 300;
var i;
for (i = 2; i < maxIterator; i++) {
let isEven = !!(i % 2);
let addToCurrentValue = isEven
? 5
: 6;
currentValue += addToCurrentValue;
console.log(`a=${currentValue}`);
const IntlPolyfill = require("intl");
Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
const express = require("express");
const next = require("next");
const LRUCache = require("lru-cache");
const accepts = require("accepts");
const path = require("path");
const dev = process.env.NODE_ENV !== "production";
### Keybase proof
I hereby claim:
* I am vernondegoede on github.
* I am vernondg (https://keybase.io/vernondg) on keybase.
* I have a public key ASBxofN0mQGvcyjl5oounKTUbXgNxReBh7AZTpSzMgtijwo
To claim this, I am signing this object:
@vernondegoede
vernondegoede / upgrade.js
Created November 14, 2016 15:54
IAP reproduction steps
const FLOXER_PRO_IOS_PRODUCT_ID = 'com.coqtail.floxer.pro_account';
window.inAppPurchase
.getProducts([FLOXER_PRO_IOS_PRODUCT_ID])
.then(function (products) {
console.log(products); // Returns: []
window.inAppPurchase
.buy(FLOXER_PRO_IOS_PRODUCT_ID)
.then(function (data) {