Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various changes; added Cancellation API #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Created by .ignore support plugin (hsz.mobi)
### Ruby template
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
Gemfile.lock
# .ruby-version
# .ruby-gemset
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in paymentwall.gemspec
gemspec
134 changes: 70 additions & 64 deletions lib/Paymentwall/Base.rb
Original file line number Diff line number Diff line change
@@ -1,66 +1,72 @@
require 'digest'

module Paymentwall
class Base

VERSION = '1.0.0'

API_VC = 1
API_GOODS = 2
API_CART = 3

CONTROLLER_PAYMENT_VIRTUAL_CURRENCY = 'ps'
CONTROLLER_PAYMENT_DIGITAL_GOODS = 'subscription'
CONTROLLER_PAYMENT_CART = 'cart'

DEFAULT_SIGNATURE_VERSION = 3
SIGNATURE_VERSION_1 = 1
SIGNATURE_VERSION_2 = 2
SIGNATURE_VERSION_3 = 3

@@apiType
@@appKey
@@secretKey

def self.setApiType(value)
@@apiType = value
self
end

def self.getApiType
@@apiType
end

def self.setAppKey(value)
@@appKey = value
self
end

def self.getAppKey
@@appKey
end

def self.setSecretKey(value)
@@secretKey = value
self
end

def self.getSecretKey
@@secretKey
end

def getErrors
@errors
end

def getErrorSummary
@errors.join("\n")
end

protected

def appendToErrors(err)
@errors ||=[]
@errors.push(err)
self
end
end
class Base

VERSION = '1.0.0'

API_VC = 1
API_GOODS = 2
API_CART = 3

CONTROLLER_PAYMENT_VIRTUAL_CURRENCY = 'ps'
CONTROLLER_PAYMENT_DIGITAL_GOODS = 'subscription'
CONTROLLER_PAYMENT_CART = 'cart'

DEFAULT_SIGNATURE_VERSION = 3
SIGNATURE_VERSION_1 = 1
SIGNATURE_VERSION_2 = 2
SIGNATURE_VERSION_3 = 3

@@api_type = nil
@@app_key = nil
@@secret_key = nil

def self.setApiType(value)
@@api_type = value
self
end

def self.getApiType
@@api_type
end

def self.setAppKey(value)
@@app_key = value
self
end

def self.getAppKey
@@app_key
end

def self.setSecretKey(value)
@@secret_key = value
self
end

def self.getSecretKey
@@secret_key
end

def getErrors
@errors
end

def getErrorSummary
@errors.join("\n")
end

protected

def self.getDefaultSignatureVersion()
return getApiType() != API_CART ? DEFAULT_SIGNATURE_VERSION : SIGNATURE_VERSION_2
end

def appendToErrors(err)
@errors ||=[]
@errors.push(err)
self
end
end
end
Loading