payment_recipes 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/payment_recipes/paypal/rest/action/capture_authorization.rb +27 -0
- data/lib/payment_recipes/paypal/rest/action/create_payment.rb +73 -0
- data/lib/payment_recipes/paypal/rest/action/execute_payment.rb +25 -0
- data/lib/payment_recipes/paypal/rest/action/refund_capture.rb +24 -0
- data/lib/payment_recipes/paypal/rest/action/refund_sale.rb +24 -0
- data/lib/payment_recipes/paypal/rest/action/void_authorization.rb +24 -0
- data/lib/payment_recipes/paypal/rest/authorization.rb +172 -0
- data/lib/payment_recipes/paypal/rest/capture.rb +140 -0
- data/lib/payment_recipes/paypal/rest/payer.rb +38 -0
- data/lib/payment_recipes/paypal/rest/payment.rb +126 -0
- data/lib/payment_recipes/paypal/rest/refund.rb +160 -0
- data/lib/payment_recipes/paypal/rest/sale.rb +172 -0
- data/lib/payment_recipes/paypal/rest/settings.rb +18 -0
- data/lib/payment_recipes/paypal/rest/transaction.rb +118 -0
- data/lib/payment_recipes/paypal/soap/action/capture_authorization.rb +104 -0
- data/lib/payment_recipes/paypal/soap/action/create_express_checkout_payment.rb +76 -0
- data/lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb +131 -0
- data/lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb +62 -0
- data/lib/payment_recipes/paypal/soap/settings.rb +22 -0
- data/lib/payment_recipes/paypal/soap/transaction.rb +116 -0
- data/lib/payment_recipes/utils/action.rb +145 -8
- data/lib/payment_recipes/version.rb +1 -1
- data/lib/payment_recipes.rb +24 -15
- metadata +37 -17
- data/lib/payment_recipes/paypal/action/capture_authorization.rb +0 -25
- data/lib/payment_recipes/paypal/action/create_payment.rb +0 -66
- data/lib/payment_recipes/paypal/action/execute_payment.rb +0 -17
- data/lib/payment_recipes/paypal/action/refund_capture.rb +0 -22
- data/lib/payment_recipes/paypal/action/refund_sale.rb +0 -22
- data/lib/payment_recipes/paypal/action/void_authorization.rb +0 -22
- data/lib/payment_recipes/paypal/authorization.rb +0 -170
- data/lib/payment_recipes/paypal/capture.rb +0 -138
- data/lib/payment_recipes/paypal/payer.rb +0 -36
- data/lib/payment_recipes/paypal/payment.rb +0 -124
- data/lib/payment_recipes/paypal/refund.rb +0 -158
- data/lib/payment_recipes/paypal/sale.rb +0 -170
- data/lib/payment_recipes/paypal/settings.rb +0 -14
- data/lib/payment_recipes/paypal/transaction.rb +0 -116
@@ -0,0 +1,131 @@
|
|
1
|
+
"""
|
2
|
+
NOTES: Response Structure (action.response)
|
3
|
+
|
4
|
+
PayPal::SDK::Merchant::DataTypes::DoExpressCheckoutPaymentResponseType
|
5
|
+
├── Ack: Success
|
6
|
+
├── Build: ***
|
7
|
+
├── CorrelationID: ***
|
8
|
+
├── DoExpressCheckoutPaymentResponseDetails: PayPal::SDK::Merchant::DataTypes::DoExpressCheckoutPaymentResponseDetailsType
|
9
|
+
│ ├── CoupledPaymentInfo: PayPal::SDK::Core::API::DataTypes::ArrayWithBlock
|
10
|
+
│ │ └── 0: #<PayPal::SDK::Merchant::DataTypes::CoupledPaymentInfoType:0x007fba1a527138>
|
11
|
+
│ │
|
12
|
+
│ ├── PaymentInfo: PayPal::SDK::Core::API::DataTypes::ArrayWithBlock
|
13
|
+
│ │ └── 0: PayPal::SDK::Merchant::DataTypes::PaymentInfoType
|
14
|
+
│ │ ├── ExchangeRate: nil
|
15
|
+
│ │ ├── FeeAmount: PayPal::SDK::Merchant::DataTypes::BasicAmountType
|
16
|
+
│ │ │ ├── currencyID: USD
|
17
|
+
│ │ │ └── value: 0.36
|
18
|
+
│ │ │
|
19
|
+
│ │ ├── GrossAmount: PayPal::SDK::Merchant::DataTypes::BasicAmountType
|
20
|
+
│ │ │ ├── currencyID: USD
|
21
|
+
│ │ │ └── value: 2.00
|
22
|
+
│ │ │
|
23
|
+
│ │ ├── ParentTransactionID: nil
|
24
|
+
│ │ ├── PaymentDate: 2017-02-05T17:34:13+00:00
|
25
|
+
│ │ ├── PaymentStatus: Completed
|
26
|
+
│ │ ├── PaymentType: instant
|
27
|
+
│ │ ├── PendingReason: none
|
28
|
+
│ │ ├── ProtectionEligibility: Eligible
|
29
|
+
│ │ ├── ProtectionEligibilityType: ItemNotReceivedEligible,UnauthorizedPaymentEligible
|
30
|
+
│ │ ├── ReasonCode: none
|
31
|
+
│ │ ├── ReceiptID: nil
|
32
|
+
│ │ ├── SellerDetails: PayPal::SDK::Merchant::DataTypes::SellerDetailsType
|
33
|
+
│ │ │ └── SecureMerchantAccountID: ***
|
34
|
+
│ │ │
|
35
|
+
│ │ ├── TaxAmount: PayPal::SDK::Merchant::DataTypes::BasicAmountType
|
36
|
+
│ │ │ ├── currencyID: USD
|
37
|
+
│ │ │ └── value: 0.00
|
38
|
+
│ │ │
|
39
|
+
│ │ ├── TransactionID: ***
|
40
|
+
│ │ └── TransactionType: express-checkout
|
41
|
+
│ │
|
42
|
+
│ ├── SuccessPageRedirectRequested: false
|
43
|
+
│ └── Token: ***
|
44
|
+
│
|
45
|
+
├── Timestamp: ***
|
46
|
+
└── Version: ***
|
47
|
+
"""
|
48
|
+
|
49
|
+
module PaymentRecipes
|
50
|
+
module PayPal
|
51
|
+
module SOAP
|
52
|
+
module Action
|
53
|
+
class ExecuteExpressCheckout < PaymentRecipes::Utils::Action
|
54
|
+
variable :token, "String"
|
55
|
+
variable :payer_id, "String"
|
56
|
+
variable :details, "Hash"
|
57
|
+
variable :intent, "Symbol"
|
58
|
+
|
59
|
+
def perform
|
60
|
+
prepare_soap_api
|
61
|
+
modify_details
|
62
|
+
do_express_checkout
|
63
|
+
|
64
|
+
if response.success?
|
65
|
+
load_transaction
|
66
|
+
end
|
67
|
+
|
68
|
+
response
|
69
|
+
end
|
70
|
+
|
71
|
+
def prepare_soap_api
|
72
|
+
store(:api) do
|
73
|
+
::PaymentRecipes::PayPal::SOAP::Settings.api
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def modify_details
|
78
|
+
unless [:sale, :authorize].include?(intent)
|
79
|
+
raise Exception, "Allowed values for intent: :sale, :authorize"
|
80
|
+
end
|
81
|
+
|
82
|
+
store(:express_checkout_details) do
|
83
|
+
payment_action = if intent == :sale
|
84
|
+
'Sale'
|
85
|
+
elsif intent == :authorize
|
86
|
+
'Authorization'
|
87
|
+
end
|
88
|
+
|
89
|
+
{
|
90
|
+
:DoExpressCheckoutPaymentRequestDetails => {
|
91
|
+
:PaymentAction => payment_action,
|
92
|
+
:Token => token,
|
93
|
+
:PayerID => payer_id,
|
94
|
+
:PaymentDetails => [details]
|
95
|
+
}
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def response
|
101
|
+
do_express_checkout_response
|
102
|
+
end
|
103
|
+
|
104
|
+
def do_express_checkout
|
105
|
+
do_express_checkout_payment = api.build_do_express_checkout_payment(express_checkout_details)
|
106
|
+
|
107
|
+
store(:do_express_checkout_response) do
|
108
|
+
response = api.do_express_checkout_payment(do_express_checkout_payment)
|
109
|
+
|
110
|
+
unless response.success?
|
111
|
+
@error = response.errors
|
112
|
+
|
113
|
+
response = nil
|
114
|
+
end
|
115
|
+
|
116
|
+
response
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def load_transaction
|
121
|
+
store(:transaction) do
|
122
|
+
transaction_id = response.do_express_checkout_payment_response_details.payment_info.first.transaction_id
|
123
|
+
|
124
|
+
::PaymentRecipes::PayPal::SOAP::Transaction.find(transaction_id)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module PaymentRecipes
|
2
|
+
module PayPal
|
3
|
+
module SOAP
|
4
|
+
module Action
|
5
|
+
class PerformDirectPayment < PaymentRecipes::Utils::Action
|
6
|
+
variable :details, "Hash"
|
7
|
+
variable :intent, "Symbol"
|
8
|
+
|
9
|
+
def perform
|
10
|
+
prepare_soap_api
|
11
|
+
modify_details
|
12
|
+
perform_request
|
13
|
+
|
14
|
+
if response.success?
|
15
|
+
load_transaction
|
16
|
+
end
|
17
|
+
|
18
|
+
response
|
19
|
+
end
|
20
|
+
|
21
|
+
def prepare_soap_api
|
22
|
+
store(:api) do
|
23
|
+
::PaymentRecipes::PayPal::SOAP::Settings.api
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def modify_details
|
28
|
+
unless [:sale, :authorize].include?(intent)
|
29
|
+
raise Exception, "Allowed values for intent: :sale, :authorize"
|
30
|
+
end
|
31
|
+
|
32
|
+
store(:direct_payment_details) do
|
33
|
+
payment_action = if intent == :sale
|
34
|
+
'Sale'
|
35
|
+
elsif intent == :authorize
|
36
|
+
'Authorization'
|
37
|
+
end
|
38
|
+
|
39
|
+
details[:DoDirectPaymentRequestDetails][:PaymentAction] = payment_action
|
40
|
+
|
41
|
+
details
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def perform_request
|
46
|
+
do_direct_payment = api.build_do_direct_payment(direct_payment_details)
|
47
|
+
|
48
|
+
store(:response) do
|
49
|
+
api.do_direct_payment(do_direct_payment)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_transaction
|
54
|
+
store(:transaction) do
|
55
|
+
::PaymentRecipes::PayPal::SOAP::Transaction.find(response.transaction_id)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PaymentRecipes
|
2
|
+
module PayPal
|
3
|
+
module SOAP
|
4
|
+
class Settings
|
5
|
+
def self.configure(live: false, app_id:, username:, password:, signature:)
|
6
|
+
mode = live ? "live" : "sandbox"
|
7
|
+
|
8
|
+
::PayPal::SDK.configure(
|
9
|
+
:mode => mode,
|
10
|
+
:app_id => app_id,
|
11
|
+
:username => username,
|
12
|
+
:password => password,
|
13
|
+
:signature => signature )
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.api
|
17
|
+
::PayPal::SDK::Merchant.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module PaymentRecipes
|
2
|
+
module PayPal
|
3
|
+
module SOAP
|
4
|
+
class Transaction
|
5
|
+
attr_reader :raw_transaction
|
6
|
+
|
7
|
+
attr_reader :id
|
8
|
+
attr_reader :correlation_id
|
9
|
+
attr_reader :timestamp
|
10
|
+
attr_reader :transaction_type
|
11
|
+
|
12
|
+
attr_reader :gross_amount
|
13
|
+
attr_reader :fee_amount
|
14
|
+
attr_reader :tax_amount
|
15
|
+
attr_reader :payment_item_amount
|
16
|
+
|
17
|
+
attr_reader :payment_date
|
18
|
+
attr_reader :payment_type
|
19
|
+
attr_reader :payment_status
|
20
|
+
attr_reader :pending_reason
|
21
|
+
|
22
|
+
attr_reader :parent_transaction_id
|
23
|
+
|
24
|
+
include ::PaymentRecipes::Utils::Converters
|
25
|
+
include ::PaymentRecipes::Utils::Equality
|
26
|
+
|
27
|
+
def initialize(paypal_transaction, id: nil)
|
28
|
+
unless paypal_transaction.is_a?(::PayPal::SDK::Merchant::DataTypes::GetTransactionDetailsResponseType)
|
29
|
+
raise Exception, "#{ self.class.name } must be initialized with a PayPal Transaction"
|
30
|
+
end
|
31
|
+
|
32
|
+
extract_and_store(paypal_transaction)
|
33
|
+
end
|
34
|
+
|
35
|
+
def extract_and_store(paypal_transaction)
|
36
|
+
@raw_transaction = paypal_transaction
|
37
|
+
|
38
|
+
@id = id || paypal_transaction.payment_transaction_details.payment_info.transaction_id
|
39
|
+
@correlation_id = paypal_transaction.correlation_id
|
40
|
+
@timestamp = paypal_transaction.timestamp.to_time
|
41
|
+
|
42
|
+
@transaction_type = paypal_transaction.payment_transaction_details.payment_info.transaction_type.to_s
|
43
|
+
@payment_type = paypal_transaction.payment_transaction_details.payment_info.payment_type.to_s
|
44
|
+
@payment_status = paypal_transaction.payment_transaction_details.payment_info.payment_status.to_s
|
45
|
+
@pending_reason = paypal_transaction.payment_transaction_details.payment_info.pending_reason.to_s
|
46
|
+
@parent_transaction_id = paypal_transaction.payment_transaction_details.payment_info.parent_transaction_id.to_s
|
47
|
+
@payment_date = paypal_transaction.payment_transaction_details.payment_info.payment_date.to_time
|
48
|
+
|
49
|
+
paypal_gross_amount = paypal_transaction.payment_transaction_details.payment_info.gross_amount
|
50
|
+
@gross_amount = convert_to_money(amount: paypal_gross_amount.value, currency: paypal_gross_amount.currencyID)
|
51
|
+
|
52
|
+
paypal_fee_amount = paypal_transaction.payment_transaction_details.payment_info.fee_amount
|
53
|
+
@fee_amount = convert_to_money(amount: paypal_fee_amount.value, currency: paypal_fee_amount.currencyID)
|
54
|
+
|
55
|
+
paypal_tax_amount = paypal_transaction.payment_transaction_details.payment_info.tax_amount
|
56
|
+
@tax_amount = convert_to_money(amount: paypal_tax_amount.value, currency: paypal_tax_amount.currencyID)
|
57
|
+
|
58
|
+
payment_item_amount = paypal_transaction.payment_transaction_details.payment_item_info.payment_item.first.amount
|
59
|
+
@payment_item_amount = convert_to_money(amount: payment_item_amount.value, currency: payment_item_amount.currencyID)
|
60
|
+
end
|
61
|
+
|
62
|
+
def pending?
|
63
|
+
@payment_status == "Pending"
|
64
|
+
end
|
65
|
+
|
66
|
+
def complete?
|
67
|
+
@payment_status == "Completed"
|
68
|
+
end
|
69
|
+
|
70
|
+
def inspect
|
71
|
+
to_str
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_s
|
75
|
+
to_str
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_str
|
79
|
+
if pending?
|
80
|
+
"<#{ self.class.name } type=#{ @transaction_type } payment_type=#{ @payment_type } payment_status=#{ @payment_status } [#{ @pending_reason }] id=#{ @id }>"
|
81
|
+
else
|
82
|
+
"<#{ self.class.name } type=#{ @transaction_type } payment_type=#{ @payment_type } payment_status=#{ @payment_status } id=#{ @id }>"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class << self
|
87
|
+
def find(id)
|
88
|
+
paypal_transaction = find_raw(id)
|
89
|
+
|
90
|
+
if paypal_transaction
|
91
|
+
new(paypal_transaction, id: id)
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_raw(id)
|
98
|
+
api = ::PaymentRecipes::PayPal::SOAP::Settings.api
|
99
|
+
|
100
|
+
begin
|
101
|
+
get_transaction_details = api.build_get_transaction_details({
|
102
|
+
:TransactionID => id })
|
103
|
+
|
104
|
+
response = api.get_transaction_details(get_transaction_details)
|
105
|
+
|
106
|
+
response
|
107
|
+
|
108
|
+
rescue Exception
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
class SamplePaymentAction < PaymentRecipes::Utils::Action
|
3
|
+
variable :x, 'Integer'
|
4
|
+
|
5
|
+
def perform
|
6
|
+
if x
|
7
|
+
puts x + 1
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
action = SamplePaymentAction.prepare(x: nil)
|
13
|
+
action.execute
|
14
|
+
"""
|
15
|
+
|
1
16
|
module PaymentRecipes
|
2
17
|
module Utils
|
3
18
|
class Action
|
@@ -12,28 +27,150 @@ module PaymentRecipes
|
|
12
27
|
end
|
13
28
|
|
14
29
|
def rules
|
15
|
-
@rules
|
30
|
+
@rules || []
|
16
31
|
end
|
17
32
|
|
18
|
-
def prepare(parameters)
|
19
|
-
|
20
|
-
unless parameters[key].is_a?(klass)
|
21
|
-
|
33
|
+
def prepare(parameters = {})
|
34
|
+
rules.each do |key, klass|
|
35
|
+
# unless parameters[key].is_a?(klass.constantize)# || parameters[key].is_a?(NilClass)
|
36
|
+
allowed_class_strings = parameters[key].class.ancestors.map(&:to_s)
|
37
|
+
unless allowed_class_strings.include?(klass) || allowed_class_strings.include?("NilClass")
|
38
|
+
raise TypeError, "#{ key } should be a #{ klass }"
|
22
39
|
end
|
23
40
|
end
|
24
41
|
|
25
|
-
new(parameters)
|
42
|
+
output = new(parameters)
|
43
|
+
output.instance_variable_set(:@_action_state, :prepared)
|
44
|
+
|
45
|
+
output
|
46
|
+
end
|
47
|
+
|
48
|
+
def debug
|
49
|
+
study rules
|
26
50
|
end
|
27
51
|
end
|
28
52
|
|
29
|
-
def initialize(parameters)
|
30
|
-
raise
|
53
|
+
def initialize(parameters = {})
|
54
|
+
raise TypeError, "Action params should be a Hash" unless parameters.is_a?(Hash)
|
31
55
|
|
32
56
|
@params = parameters
|
33
57
|
@params.each do |param, value|
|
34
58
|
instance_variable_set("@#{ param }".to_sym, value)
|
35
59
|
end
|
36
60
|
end
|
61
|
+
|
62
|
+
def success?
|
63
|
+
@success
|
64
|
+
end
|
65
|
+
|
66
|
+
def failure?
|
67
|
+
not success?
|
68
|
+
end
|
69
|
+
|
70
|
+
def execute
|
71
|
+
@success = nil
|
72
|
+
@error = nil
|
73
|
+
|
74
|
+
unless @_action_state
|
75
|
+
raise Exception, "Use #{ self.class.name }.prepare to initialize this action"
|
76
|
+
end
|
77
|
+
|
78
|
+
unless @_action_state == :executed
|
79
|
+
@_action_output = perform
|
80
|
+
|
81
|
+
if @error
|
82
|
+
@success = false
|
83
|
+
else
|
84
|
+
@success = true
|
85
|
+
end
|
86
|
+
|
87
|
+
make_instance_variables_available
|
88
|
+
|
89
|
+
@_action_state = :executed
|
90
|
+
end
|
91
|
+
|
92
|
+
@_action_output
|
93
|
+
end
|
94
|
+
|
95
|
+
def stored_variables
|
96
|
+
output = {}
|
97
|
+
|
98
|
+
instance_variables.each do |instance_variable|
|
99
|
+
instance_variable_sym = instance_variable.to_s.gsub("@", "").to_sym
|
100
|
+
|
101
|
+
begin
|
102
|
+
output[instance_variable_sym] = send(instance_variable_sym)
|
103
|
+
rescue Exception => e
|
104
|
+
# NOTE: do nothing
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
output
|
109
|
+
end
|
110
|
+
|
111
|
+
def make_instance_variables_available
|
112
|
+
instance_variables.each do |instance_variable|
|
113
|
+
define_singleton_method(instance_variable.to_s.gsub("@", "")) do
|
114
|
+
instance_variable_get(instance_variable)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def ensure_presence(variable, default: nil)
|
120
|
+
if variable.present?
|
121
|
+
yield if block_given?
|
122
|
+
else
|
123
|
+
default
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
"""
|
128
|
+
memoize(:x) do
|
129
|
+
puts 'executed'
|
130
|
+
42
|
131
|
+
end
|
132
|
+
"""
|
133
|
+
def store(label)
|
134
|
+
label_sym = "@#{label}".to_sym
|
135
|
+
|
136
|
+
if stored_value = instance_variable_get(label_sym)
|
137
|
+
stored_value
|
138
|
+
else
|
139
|
+
if block_given?
|
140
|
+
computed_value = yield
|
141
|
+
|
142
|
+
instance_variable_set(label_sym, computed_value)
|
143
|
+
|
144
|
+
define_singleton_method(label_sym.to_s.gsub("@", "")) do
|
145
|
+
instance_variable_get(label_sym)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
instance_variable_get(label_sym)
|
151
|
+
end
|
152
|
+
|
153
|
+
def set(label, value)
|
154
|
+
label_sym = "@#{label}".to_sym
|
155
|
+
|
156
|
+
instance_variable_set(label_sym, value)
|
157
|
+
|
158
|
+
define_singleton_method(label_sym.to_s.gsub("@", "")) do
|
159
|
+
instance_variable_get(label_sym)
|
160
|
+
end
|
161
|
+
|
162
|
+
value
|
163
|
+
end
|
164
|
+
|
165
|
+
def get(label)
|
166
|
+
label_sym = "@#{label}".to_sym
|
167
|
+
|
168
|
+
instance_variable_get(label_sym)
|
169
|
+
end
|
170
|
+
|
171
|
+
def debug
|
172
|
+
study @params
|
173
|
+
end
|
37
174
|
end
|
38
175
|
end
|
39
176
|
end
|
data/lib/payment_recipes.rb
CHANGED
@@ -8,20 +8,29 @@ require 'payment_recipes/utils/action'
|
|
8
8
|
require 'payment_recipes/utils/converters'
|
9
9
|
require 'payment_recipes/utils/equality'
|
10
10
|
|
11
|
-
require 'payment_recipes/paypal/settings'
|
12
|
-
require 'payment_recipes/paypal/authorization'
|
13
|
-
require 'payment_recipes/paypal/capture'
|
14
|
-
require 'payment_recipes/paypal/payer'
|
15
|
-
require 'payment_recipes/paypal/payment'
|
16
|
-
require 'payment_recipes/paypal/refund'
|
17
|
-
require 'payment_recipes/paypal/sale'
|
18
|
-
require 'payment_recipes/paypal/transaction'
|
11
|
+
require 'payment_recipes/paypal/rest/settings'
|
12
|
+
require 'payment_recipes/paypal/rest/authorization'
|
13
|
+
require 'payment_recipes/paypal/rest/capture'
|
14
|
+
require 'payment_recipes/paypal/rest/payer'
|
15
|
+
require 'payment_recipes/paypal/rest/payment'
|
16
|
+
require 'payment_recipes/paypal/rest/refund'
|
17
|
+
require 'payment_recipes/paypal/rest/sale'
|
18
|
+
require 'payment_recipes/paypal/rest/transaction'
|
19
19
|
|
20
|
-
require 'payment_recipes/paypal/action/capture_authorization'
|
21
|
-
require 'payment_recipes/paypal/action/create_payment'
|
22
|
-
require 'payment_recipes/paypal/action/execute_payment'
|
23
|
-
require 'payment_recipes/paypal/action/refund_capture'
|
24
|
-
require 'payment_recipes/paypal/action/refund_sale'
|
25
|
-
require 'payment_recipes/paypal/action/void_authorization'
|
20
|
+
require 'payment_recipes/paypal/rest/action/capture_authorization'
|
21
|
+
require 'payment_recipes/paypal/rest/action/create_payment'
|
22
|
+
require 'payment_recipes/paypal/rest/action/execute_payment'
|
23
|
+
require 'payment_recipes/paypal/rest/action/refund_capture'
|
24
|
+
require 'payment_recipes/paypal/rest/action/refund_sale'
|
25
|
+
require 'payment_recipes/paypal/rest/action/void_authorization'
|
26
26
|
|
27
|
-
I18n.config.available_locales = :en
|
27
|
+
I18n.config.available_locales = :en
|
28
|
+
|
29
|
+
require 'paypal-sdk-merchant'
|
30
|
+
|
31
|
+
require 'payment_recipes/paypal/soap/settings'
|
32
|
+
require 'payment_recipes/paypal/soap/transaction'
|
33
|
+
require 'payment_recipes/paypal/soap/action/perform_direct_payment'
|
34
|
+
require 'payment_recipes/paypal/soap/action/capture_authorization'
|
35
|
+
require 'payment_recipes/paypal/soap/action/create_express_checkout_payment'
|
36
|
+
require 'payment_recipes/paypal/soap/action/execute_express_checkout_payment'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payment_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Arvin Lat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: paypal-sdk-merchant
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.106.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.106.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,20 +88,26 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- lib/payment_recipes.rb
|
77
|
-
- lib/payment_recipes/paypal/action/capture_authorization.rb
|
78
|
-
- lib/payment_recipes/paypal/action/create_payment.rb
|
79
|
-
- lib/payment_recipes/paypal/action/execute_payment.rb
|
80
|
-
- lib/payment_recipes/paypal/action/refund_capture.rb
|
81
|
-
- lib/payment_recipes/paypal/action/refund_sale.rb
|
82
|
-
- lib/payment_recipes/paypal/action/void_authorization.rb
|
83
|
-
- lib/payment_recipes/paypal/authorization.rb
|
84
|
-
- lib/payment_recipes/paypal/capture.rb
|
85
|
-
- lib/payment_recipes/paypal/payer.rb
|
86
|
-
- lib/payment_recipes/paypal/payment.rb
|
87
|
-
- lib/payment_recipes/paypal/refund.rb
|
88
|
-
- lib/payment_recipes/paypal/sale.rb
|
89
|
-
- lib/payment_recipes/paypal/settings.rb
|
90
|
-
- lib/payment_recipes/paypal/transaction.rb
|
91
|
+
- lib/payment_recipes/paypal/rest/action/capture_authorization.rb
|
92
|
+
- lib/payment_recipes/paypal/rest/action/create_payment.rb
|
93
|
+
- lib/payment_recipes/paypal/rest/action/execute_payment.rb
|
94
|
+
- lib/payment_recipes/paypal/rest/action/refund_capture.rb
|
95
|
+
- lib/payment_recipes/paypal/rest/action/refund_sale.rb
|
96
|
+
- lib/payment_recipes/paypal/rest/action/void_authorization.rb
|
97
|
+
- lib/payment_recipes/paypal/rest/authorization.rb
|
98
|
+
- lib/payment_recipes/paypal/rest/capture.rb
|
99
|
+
- lib/payment_recipes/paypal/rest/payer.rb
|
100
|
+
- lib/payment_recipes/paypal/rest/payment.rb
|
101
|
+
- lib/payment_recipes/paypal/rest/refund.rb
|
102
|
+
- lib/payment_recipes/paypal/rest/sale.rb
|
103
|
+
- lib/payment_recipes/paypal/rest/settings.rb
|
104
|
+
- lib/payment_recipes/paypal/rest/transaction.rb
|
105
|
+
- lib/payment_recipes/paypal/soap/action/capture_authorization.rb
|
106
|
+
- lib/payment_recipes/paypal/soap/action/create_express_checkout_payment.rb
|
107
|
+
- lib/payment_recipes/paypal/soap/action/execute_express_checkout_payment.rb
|
108
|
+
- lib/payment_recipes/paypal/soap/action/perform_direct_payment.rb
|
109
|
+
- lib/payment_recipes/paypal/soap/settings.rb
|
110
|
+
- lib/payment_recipes/paypal/soap/transaction.rb
|
91
111
|
- lib/payment_recipes/utils/action.rb
|
92
112
|
- lib/payment_recipes/utils/converters.rb
|
93
113
|
- lib/payment_recipes/utils/equality.rb
|
@@ -112,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
132
|
version: '0'
|
113
133
|
requirements: []
|
114
134
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.5.1
|
116
136
|
signing_key:
|
117
137
|
specification_version: 4
|
118
138
|
summary: Wrapper classes and utilities to speed up payment gateway integration
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module PaymentRecipes
|
2
|
-
module PayPal
|
3
|
-
module Action
|
4
|
-
class CaptureAuthorization < PaymentRecipes::Utils::Action
|
5
|
-
variable :authorization, ::PaymentRecipes::PayPal::Authorization
|
6
|
-
|
7
|
-
def perform
|
8
|
-
if @authorization.can_be_captured?
|
9
|
-
currency = @authorization.currency
|
10
|
-
total = @authorization.total.to_s
|
11
|
-
|
12
|
-
@authorization.raw_authorization.capture({:amount => { :currency => currency, :total => total } })
|
13
|
-
|
14
|
-
@authorization.reload!
|
15
|
-
@authorization.reload_payment!
|
16
|
-
else
|
17
|
-
raise Exception, "Authorization can't be captured"
|
18
|
-
end
|
19
|
-
|
20
|
-
@authorization
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|