Class: Pay

Inherits:
Object
  • Object
show all
Defined in:
lib/mozpay/base.rb

Constant Summary collapse

@@purchaseQueue =

This array keeps track of the tokens waiting for marketplace responses

{}

Class Method Summary collapse

Class Method Details

.checkQueue(token) ⇒ Object

Check purchaseQueue to see if token has resolved

Parameters:

  • token (Object)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mozpay/base.rb', line 22

def self.checkQueue(token)
   	status = @@purchaseQueue[token]
   	if status
   		if status != 'processing'
        	delete @@purchaseQueue[token]
    	end
    	return status || 'notfound'
    else
    	return 'notfound'
   	end
end

.hiObject

This is here solely to make sure I set up tests correctly.



7
8
9
# File 'lib/mozpay/base.rb', line 7

def self.hi
	return "Hello world!"
end

.request(payload) ⇒ Object

Encode a JWT payment request.

Parameters:

  • request (Object)


94
95
96
97
98
# File 'lib/mozpay/base.rb', line 94

def self.request(payload)
	jwt_encoded = JWT.encode(payload, config.mozPaySecret, "HS256")
	purchaseQueue[payload[productData]] = 'processing';
	return jwt_encoded
end