From a73e887a4a7b8fdaadb9d8c5d7323cccfb726680 Mon Sep 17 00:00:00 2001
From: Louis Kearns
Date: Wed, 3 Sep 2014 14:57:22 -0400
Subject: [PATCH 01/56] Update Readme File
Elaborate instructions based on common questions
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index c22d2dc..bca66ba 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,8 @@ Once we enable developer mode, which normally happens the same day, you'll be re
> We are providing this simple implementation of an Offsite Gateway Sim as a way to demonstrate basics of this new API. If you want to see it in action, leave ``POST URL`` on your **Universal Offsite Dev Kit** empty, or set it to ``https://offsite-gateway-sim.herokuapp.com/``, then try placing another order in your test shop.
+> Note: The **Universal Offsite Dev Kit** will not support a separate ``POST URL`` for each merchant. However, you can get around this by using some field identifier (eg/ common prefix of the ``x_account_id`` field) as a basis to redirect from the POST URL to an appropriate hosted payment page based on that identifier.
+
### Payment Flow
+ Customer initiates checkout on the Shopify storefront
@@ -59,8 +61,9 @@ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'secret key', message)
### Going Live
-As soon as you are confident that your implementation is complete, we'll need to collect some more information about your gateway,
+As soon as you are confident that your implementation is complete, please send another email to payment-integrations@shopify.com with the following details:
+ + A link to a live (non-test) order processed with the Universal DevKit. eg/ ``http://shopname.myshopify.com/orders/123123123``
+ Names for any fields that your gateway will require shops to input when setting it up within Shopify.
+ Your gateway name
+ Label for the ``x_account_id`` field, needs to match your existing terminology, e.g. ``Merchant ID`` or ``Account #``
@@ -70,7 +73,6 @@ As soon as you are confident that your implementation is complete, we'll need to
+ Image to display to customers during checkout process that identifies your gateway's supported payment options (PNG, height: 20px, max width: 340px). You may or may not want to include your gateway's logo along with this list, depending on whether it will be recognized by customers on checkout.
+ Finally, please indicate whether or not your gateway supports ``x_test`` mode
-
### Request Values
| Key | Type | Mandatory | Example | Comment |
From 11e13f02046d2b6917dab9582fe83e2a4079d272 Mon Sep 17 00:00:00 2001
From: Justin Mutter
Date: Wed, 3 Sep 2014 17:34:28 -0400
Subject: [PATCH 02/56] Add initial test to make Circle happy so we can
:shipit:
---
Gemfile | 5 +++++
Gemfile.lock | 3 +++
circle.yml | 3 +++
test/app_test.rb | 19 +++++++++++++++++++
4 files changed, 30 insertions(+)
create mode 100644 circle.yml
create mode 100644 test/app_test.rb
diff --git a/Gemfile b/Gemfile
index 56f82a1..e3dafda 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,11 @@ gem 'addressable'
group :development do
gem 'byebug'
end
+
+group :test do
+ gem 'rack-test'
+end
+
group :deploy do
gem 'heroku', '~> 3.8.2'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 2c572d1..c78da71 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -30,6 +30,8 @@ GEM
rack (1.5.2)
rack-protection (1.5.2)
rack
+ rack-test (0.6.2)
+ rack (>= 1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rubyzip (1.1.4)
@@ -48,4 +50,5 @@ DEPENDENCIES
heroku (~> 3.8.2)
httparty
json
+ rack-test
sinatra
diff --git a/circle.yml b/circle.yml
new file mode 100644
index 0000000..fcb4aed
--- /dev/null
+++ b/circle.yml
@@ -0,0 +1,3 @@
+test:
+ override:
+ - bundle exec ruby test/app_test.rb
diff --git a/test/app_test.rb b/test/app_test.rb
new file mode 100644
index 0000000..dcab1c6
--- /dev/null
+++ b/test/app_test.rb
@@ -0,0 +1,19 @@
+ENV['RACK_ENV'] = 'test'
+
+require_relative '../app'
+require 'test/unit'
+require 'rack/test'
+
+class OffsiteGatewaySimTest < Test::Unit::TestCase
+ include Rack::Test::Methods
+
+ def app
+ OffsiteGatewaySim
+ end
+
+ def test_get_root
+ get '/'
+ assert last_response.ok?
+ end
+
+end
From aefc278d628957912c7fd508d97362873c6f9910 Mon Sep 17 00:00:00 2001
From: Louis Kearns
Date: Wed, 17 Sep 2014 13:09:59 -0400
Subject: [PATCH 03/56] update instructions & reference signature calculator
---
README.md | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index bca66ba..482d51e 100644
--- a/README.md
+++ b/README.md
@@ -46,19 +46,21 @@ All requests and responses must be signed/verified using ``HMAC-SHA256`` ([HMAC]
+ Resulting codes must be hex-encoded and passed as value of ``x_signature``
+ Make sure to use case-insensitive comparison when verifying provided ``x_signature`` values
-For example,
+For example, (assuming your ``HMAC key`` is "iU44RWxeik"):
```ruby
-fields = {x_account_id: 123, x_currency: 'USD'}
-=> {:x_account_id=>123, :x_currency=>"USD"}
+fields = {x_account_id: Z9s7Yt0Txsqbbx, x_amount: 89.99, x_currency: 'USD', x_gateway_reference: '123', x_reference: "19783", x_result: "completed", x_test: "true", x_timestamp: '2014-03-24T12:15:41Z'}
+=> {:x_account_id=>Z9s7Yt0Txsqbbx, :x_amount=>89.99, :x_currency=>"USD", :x_gateway_reference=>"123", :x_reference=>"19783", :x_result=>"completed", :x_test=>"true", :x_timestamp=>"2014-03-24T12:15:41Z"}
message = fields.sort.join
-=> "x_account_id123x_currencyUSD"
-OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'secret key', message)
-=> "06ef4be2654e089b4aa346f970a71988fa3a1452acaa6273573f9db0c32ea355"
+=> "x_account_id123x_currencyUSDx_gateway_reference123x_reference19783x_resultcompletedx_testtruex_timestamp2014-03-24T12:15:41Z"
+OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'iU44RWxeik', message)
+=> "06880fd563ff6ce535d06a80ce8f2c2b79f34925d57de750ac392bc2d23c74e56"
-"x_signature=06ef4be2654e089b4aa346f970a71988fa3a1452acaa6273573f9db0c32ea355"
+"x_signature=06880fd563ff6ce535d06a80ce8f2c2b79f34925d57de750ac392bc2d23c74e56"
```
+> You may use the provided [Signature Calculator](http://offsite-gateway-sim.herokuapp.com/calculator) to confirm proper signature creation at any time.
+
### Going Live
As soon as you are confident that your implementation is complete, please send another email to payment-integrations@shopify.com with the following details:
From 5c37414966581658664597f84c2293cb9ef98806 Mon Sep 17 00:00:00 2001
From: Louis Kearns
Date: Wed, 17 Sep 2014 13:33:12 -0400
Subject: [PATCH 04/56] small tweaks
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 482d51e..2a6e4b0 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,7 @@ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), 'iU44RWxeik', message)
"x_signature=06880fd563ff6ce535d06a80ce8f2c2b79f34925d57de750ac392bc2d23c74e56"
```
-> You may use the provided [Signature Calculator](http://offsite-gateway-sim.herokuapp.com/calculator) to confirm proper signature creation at any time.
+> You may use the provided [Signature Calculator](http://offsite-gateway-sim.herokuapp.com/calculator) to confirm that your signature generation function is working appropritately.
### Going Live
@@ -119,6 +119,6 @@ As soon as you are confident that your implementation is complete, please send a
| ``x_test`` | true/false | ✓ | true | Echo request's ``x_test`` |
| ``x_amount`` | decimal | ✓ | 89.99 | Echo request's ``x_amount`` |
| ``x_gateway_reference`` | unicode string | ✓ | 123 | Unique reference for the authorization issued by the payment processor. |
-| ``x_timestamp`` | [iso-8601](http://en.wikipedia.org/wiki/ISO_8601) in UTC | ✓ | 2014-03-24T12:15:41Z | |
+| ``x_timestamp`` | [iso-8601](http://en.wikipedia.org/wiki/ISO_8601) in UTC | ✓ | 2014-03-24T12:15:41Z | UTC Time: YYYY-MM-DDTHH:MM:SSZ |
| ``x_result`` | fixed choice | ✓ | completed | One of: completed, failed, pending |
| ``x_signature`` | hex string, case-insensitive | ✓ | 3a59e201a9b8692702b8c41dcba476d4a46e5f5c | See [Signing Mechanism](#signing-mechanism). |
From 738ff73d5e2aa824c7192be1c931c8af6e977b03 Mon Sep 17 00:00:00 2001
From: Francois Chagnon
Date: Mon, 29 Sep 2014 22:10:53 +0000
Subject: [PATCH 05/56] http -> https
---
Gemfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Gemfile b/Gemfile
index e3dafda..cce639a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source 'http://rubygems.org'
+source 'https://rubygems.org'
ruby '2.1.1'
gem 'sinatra'
From 6174c5ae370d8986c992ed35ba03d92a928e48e3 Mon Sep 17 00:00:00 2001
From: Louis Kearns
Date: Wed, 1 Oct 2014 02:01:48 -0400
Subject: [PATCH 06/56] fix timestamp typo
---
response_fields.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/response_fields.yml b/response_fields.yml
index f6d8c5a..fe5481c 100644
--- a/response_fields.yml
+++ b/response_fields.yml
@@ -23,7 +23,7 @@
name: "Gateway Reference"
placeholder: "123"
-
- key: x_timespamp
+ key: x_timestamp
name: Timestamp
placeholder: "2014-03-24T12:15:41Z"
-
From 3c9627f637572acb5f4492c49f52ee984a156ce7 Mon Sep 17 00:00:00 2001
From: Louis Kearns
Date: Fri, 21 Nov 2014 10:03:53 -0500
Subject: [PATCH 07/56] update Readme
some small changes
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 2a6e4b0..6728ac0 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,9 @@ Follow these simple steps to get started.
1. Review the rest of this document
2. Sign up for a free trial of Shopify at http://www.shopify.com/. You will use this shop to place test orders against your offsite gateway.
-3. Send the name of this shop to payment-integrations@shopify.com and mention **Universal Offsite Dev Kit** in the subject
+3. Send an email to to payment-integrations@shopify.com with **Universal Offsite Dev Kit** in the subject. Be sure to include the name, url, description of the payment provider you wish to integrate, the markets it serves, your Shopify store URL, and your most recent Certificate of PCI Compliance (if you'll be accepting credit cards).
-Once we enable developer mode, which normally happens the same day, you'll be ready to proceed with integration testing.
+Once we enable developer mode, which normally happens within 48 hours, you'll be ready to proceed with integration testing.
1. [Sign in](http://www.shopify.com/login) to your Shopify store.
2. Go to [Products](http://www.shopify.com/admin/products) and [add a dummy product](http://docs.shopify.com/manual/your-store/products/create-product).
From 8145ba4b61481f7c76a1860101ca53a481cb033e Mon Sep 17 00:00:00 2001
From: "Mohammad.Hashemi"
Date: Fri, 28 Nov 2014 13:54:51 -0500
Subject: [PATCH 08/56] Updates Offsit-Sim setup instructions
---
README.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6728ac0..5a34407 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,13 @@ Follow these simple steps to get started.
1. Review the rest of this document
2. Sign up for a free trial of Shopify at http://www.shopify.com/. You will use this shop to place test orders against your offsite gateway.
-3. Send an email to to payment-integrations@shopify.com with **Universal Offsite Dev Kit** in the subject. Be sure to include the name, url, description of the payment provider you wish to integrate, the markets it serves, your Shopify store URL, and your most recent Certificate of PCI Compliance (if you'll be accepting credit cards).
+3. Send an email to to payment-integrations@shopify.com with **Universal Offsite Dev Kit** in the subject. Be sure to include:
+ + Your Shopify store URL
+ + Name, URL & description of the payment provider you wish to inegrate
+ + Markets served by this integration
+ + Your most recent Certificate of PCI Compliance (if you'll be accepting credit cards)
+ + Provider logo (minimum resolution 500 x 500 pixels) in vector format (SVG) or raster format (PNG), with a transparent background
+ + List of major supported payment methods, including all credit card brands offered
Once we enable developer mode, which normally happens within 48 hours, you'll be ready to proceed with integration testing.
From 839262e47a0513b065be6f74f23404bf460db097 Mon Sep 17 00:00:00 2001
From: "Mohammad.Hashemi"
Date: Fri, 28 Nov 2014 14:01:30 -0500
Subject: [PATCH 09/56] Updates setup instructions
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5a34407..6f9c696 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,10 @@ Follow these simple steps to get started.
+ Your Shopify store URL
+ Name, URL & description of the payment provider you wish to inegrate
+ Markets served by this integration
+ + List of major supported payment methods, including all credit card brands offered
+ Your most recent Certificate of PCI Compliance (if you'll be accepting credit cards)
+ Provider logo (minimum resolution 500 x 500 pixels) in vector format (SVG) or raster format (PNG), with a transparent background
- + List of major supported payment methods, including all credit card brands offered
+ + Test credentials for the integration
Once we enable developer mode, which normally happens within 48 hours, you'll be ready to proceed with integration testing.
From 670522bf0629c780fdde0b4577c3299f49653c51 Mon Sep 17 00:00:00 2001
From: "Mohammad.Hashemi"
Date: Fri, 28 Nov 2014 14:58:33 -0500
Subject: [PATCH 10/56] Fixes copy
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 6f9c696..fe7e672 100644
--- a/README.md
+++ b/README.md
@@ -15,8 +15,6 @@ Follow these simple steps to get started.
+ Markets served by this integration
+ List of major supported payment methods, including all credit card brands offered
+ Your most recent Certificate of PCI Compliance (if you'll be accepting credit cards)
- + Provider logo (minimum resolution 500 x 500 pixels) in vector format (SVG) or raster format (PNG), with a transparent background
- + Test credentials for the integration
Once we enable developer mode, which normally happens within 48 hours, you'll be ready to proceed with integration testing.
@@ -78,8 +76,10 @@ As soon as you are confident that your implementation is complete, please send a
+ Label for the ``x_account_id`` field, needs to match your existing terminology, e.g. ``Merchant ID`` or ``Account #``
+ Label for the ``HMAC key`` field, needs to match your existing terminology, e.g. ``Key`` or ``Shared Secret``
+ URL of a POST handler for [Request Values](#request-values) that presents a payment flow to the customer, likely the same one you used to configure *Universal Offsite Dev Kit* gateway during integration testing
+ + Test credentials for the integration
+ Your gateway's home page URL
- + Image to display to customers during checkout process that identifies your gateway's supported payment options (PNG, height: 20px, max width: 340px). You may or may not want to include your gateway's logo along with this list, depending on whether it will be recognized by customers on checkout.
+ + Provider logo (minimum resolution 500 x 500 pixels) in vector format (SVG) or raster format (PNG), with a transparent background
+ + Image to display to customers during checkout process that identifies your gateway's supported payment options (PNG, height: 20px, max width: 340px).
+ Finally, please indicate whether or not your gateway supports ``x_test`` mode
### Request Values
From 626da66e7f43c1ab027ce0349971fbc55b68381d Mon Sep 17 00:00:00 2001
From: Mohammad Hashemi
Date: Fri, 12 Dec 2014 12:55:55 -0500
Subject: [PATCH 11/56] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fe7e672..3fa5ef0 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Follow these simple steps to get started.
2. Sign up for a free trial of Shopify at http://www.shopify.com/. You will use this shop to place test orders against your offsite gateway.
3. Send an email to to payment-integrations@shopify.com with **Universal Offsite Dev Kit** in the subject. Be sure to include:
+ Your Shopify store URL
- + Name, URL & description of the payment provider you wish to inegrate
+ + Name, URL & description of the payment provider you wish to integrate
+ Markets served by this integration
+ List of major supported payment methods, including all credit card brands offered
+ Your most recent Certificate of PCI Compliance (if you'll be accepting credit cards)
From 25c7866a3c1fc4c3c7ab0b223ff6c8d8fffa6fcc Mon Sep 17 00:00:00 2001
From: Andrew P
Date: Thu, 26 Feb 2015 20:21:22 +0000
Subject: [PATCH 12/56] change to a correct signature
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3fa5ef0..d5a764d 100644
--- a/README.md
+++ b/README.md
@@ -128,4 +128,4 @@ As soon as you are confident that your implementation is complete, please send a
| ``x_gateway_reference`` | unicode string | ✓ | 123 | Unique reference for the authorization issued by the payment processor. |
| ``x_timestamp`` | [iso-8601](http://en.wikipedia.org/wiki/ISO_8601) in UTC | ✓ | 2014-03-24T12:15:41Z | UTC Time: YYYY-MM-DDTHH:MM:SSZ |
| ``x_result`` | fixed choice | ✓ | completed | One of: completed, failed, pending |
-| ``x_signature`` | hex string, case-insensitive | ✓ | 3a59e201a9b8692702b8c41dcba476d4a46e5f5c | See [Signing Mechanism](#signing-mechanism). |
+| ``x_signature`` | hex string, case-insensitive | ✓ | 49d3166063b4d881b50af0b4648c1244bfa9890a53ed6bce6d2386404b610777 | See [Signing Mechanism](#signing-mechanism). |
From 69bb3546da7c911080fd86175868794cebdd7d09 Mon Sep 17 00:00:00 2001
From: Christian Joudrey
Date: Fri, 20 Mar 2015 17:55:13 +0000
Subject: [PATCH 13/56] Add base_path such that assets work when mounted
---
app.rb | 3 ++-
views/get.erb | 4 ++--
views/layout.erb | 10 +++++-----
views/post.erb | 2 +-
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/app.rb b/app.rb
index d23b174..adda547 100644
--- a/app.rb
+++ b/app.rb
@@ -8,7 +8,8 @@
class OffsiteGatewaySim < Sinatra::Base
- def initialize
+ def initialize(base_path: '')
+ @base_path = base_path
@key = 'iU44RWxeik'
super
end
diff --git a/views/get.erb b/views/get.erb
index 6257500..17f4624 100644
--- a/views/get.erb
+++ b/views/get.erb
@@ -7,5 +7,5 @@
POST URL: https://offsite-gateway-sim.herokuapp.com/(or leave empty)
-
-
\ No newline at end of file
+
+
diff --git a/views/layout.erb b/views/layout.erb
index e843bca..11fb3ed 100644
--- a/views/layout.erb
+++ b/views/layout.erb
@@ -6,15 +6,15 @@
-
-
-
+
+
+