Sha256: 486b87f1616905f57bc10042b27e06dc1f5e2d5c724d7c8af17e6ca278b8b64e
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require '../lib/paypal-payouts-sdk' module PayPalClient class << self # Setting up and Returns PayPal SDK environment with PayPal Access credentials. # For demo purpose, we are using SandboxEnvironment. In production this will be # LiveEnvironment. def environment client_id = ENV['PAYPAL_CLIENT_ID'] || '<<PAYPAL-CLIENT-ID>>' client_secret = ENV['PAYPAL_CLIENT_SECRET'] || '<<PAYPAL-CLIENT-SECRET>>' PayPal::SandboxEnvironment.new(client_id, client_secret) end # Returns PayPal HTTP client instance with environment which has access # credentials context. This can be used invoke PayPal API's provided the # credentials have the access to do so. def client PayPal::PayPalHttpClient.new(self.environment) end # Utility to convert Openstruct Object to JSON hash. def openstruct_to_hash(object, hash = {}) object.each_pair do |key, value| hash[key] = value.is_a?(OpenStruct) ? openstruct_to_hash(value) : value.is_a?(Array) ? array_to_hash(value) : value end hash end # Utility to convert Array of OpenStruct into Hash. def array_to_hash(array, hash = []) array.each do |item| x = item.is_a?(OpenStruct) ? openstruct_to_hash(item) : item.is_a?(Array) ? array_to_hash(item) : item hash << x end hash end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
paypal-payouts-sdk-2.0.1 | samples/paypal_client.rb |
paypal-payouts-sdk-1.0.1 | samples/paypal_client.rb |
paypal-payouts-sdk-1.0.0 | samples/paypal_client.rb |