spree-paypal_merchant 6.0.1 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +7 -0
- data/app/models/spree/paypal_merchant/gateway.rb +4 -1
- data/app/models/spree/paypal_merchant/sdk_logger.rb +47 -0
- data/lib/spree/paypal_merchant/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e71ac639e1576f0bce578e79f0cfbb63ab90793d0ef55125b73c4094d7d1c3af
|
|
4
|
+
data.tar.gz: 3cccfc4d31868f2349e8c402ba45376c0c68ecff8759e9281fbdb137da4d3283
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25999fba0e7b5b6ab39121c1ed0323069bebe9874a0566daa7738860aa0624a2e69481a88b424ec97f39eff9743170d8602c9e2f6473f042f73bd4bd40ceeff7
|
|
7
|
+
data.tar.gz: 88048d65d1d028bf004cc803243b376ed7b0d7037d59575197a0d45d4e461cdcf9315031e9567e49e21a9319d3b3812d65c28f7d8eba10f494f96a9d969b79a2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.2
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- The PayPal SDK no longer writes a `WARN Request …` and `WARN Response …` line
|
|
8
|
+
to standard output for every PayPal call. Given no logger, the SDK printed to
|
|
9
|
+
standard output at the level the gem passed, outside the app's log level and
|
|
10
|
+
format. `Spree::PaypalMerchant::SdkLogger` now hands those lines to the Rails
|
|
11
|
+
log at `debug`, prefixed `[spree-paypal_merchant]`, so a production log at
|
|
12
|
+
`info` leaves them out (see "Logging" in the README).
|
|
13
|
+
|
|
3
14
|
## 6.0.1
|
|
4
15
|
|
|
5
16
|
To record refunds made in PayPal, subscribe the webhook to
|
data/README.md
CHANGED
|
@@ -207,6 +207,13 @@ Three things to know before you cut over:
|
|
|
207
207
|
id is now keyed by the cart's (or order's) prefixed id instead of the order
|
|
208
208
|
number. Such a source isn't reused, and a new one is created.
|
|
209
209
|
|
|
210
|
+
## Logging
|
|
211
|
+
|
|
212
|
+
The PayPal SDK logs one line per request and one per response: the method, URL,
|
|
213
|
+
status and content type, never bodies or headers. The gem sends these lines to
|
|
214
|
+
the Rails log at `debug`, prefixed `[spree-paypal_merchant]`, so a production
|
|
215
|
+
log at `info` leaves them out. To see them, set the log level to `debug`.
|
|
216
|
+
|
|
210
217
|
## Known limitations
|
|
211
218
|
|
|
212
219
|
- PayPal treats HUF and TWD as zero-decimal currencies, but Spree formats them
|
|
@@ -271,8 +271,11 @@ module Spree
|
|
|
271
271
|
timeout: REQUEST_TIMEOUT,
|
|
272
272
|
max_retries: MAX_RETRIES,
|
|
273
273
|
retry_methods: RETRY_METHODS,
|
|
274
|
+
# Request and response lines go to the Rails log at debug, so a
|
|
275
|
+
# production log at info leaves them out.
|
|
274
276
|
logging_configuration: PaypalServerSdk::LoggingConfiguration.new(
|
|
275
|
-
|
|
277
|
+
logger: Spree::PaypalMerchant::SdkLogger.new,
|
|
278
|
+
log_level: Logger::DEBUG,
|
|
276
279
|
request_logging_config: PaypalServerSdk::RequestLoggingConfiguration.new(
|
|
277
280
|
log_body: false
|
|
278
281
|
),
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module PaypalMerchant
|
|
5
|
+
##
|
|
6
|
+
# Hands the PayPal SDK's request and response lines to the Rails log.
|
|
7
|
+
#
|
|
8
|
+
# Given no logger, the SDK writes each line to standard output, outside
|
|
9
|
+
# the app's log level and format. It calls #log with a template such as
|
|
10
|
+
# "Request {method} {url}" and the values that fill it; a plain Logger
|
|
11
|
+
# would print the template unfilled.
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# PaypalServerSdk::LoggingConfiguration.new(logger: Spree::PaypalMerchant::SdkLogger.new, log_level: Logger::DEBUG)
|
|
15
|
+
#
|
|
16
|
+
class SdkLogger
|
|
17
|
+
PREFIX = '[spree-paypal_merchant]'
|
|
18
|
+
PLACEHOLDER = /\{([\w-]+)\}/
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# @param logger [Logger] where the lines go
|
|
22
|
+
#
|
|
23
|
+
def initialize(logger = Rails.logger)
|
|
24
|
+
@logger = logger
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# @param level [Integer] the Logger severity to write at
|
|
29
|
+
# @param message [String] the SDK's template, with {name} placeholders
|
|
30
|
+
# @param params [Hash{String, Symbol => Object}] the placeholder values
|
|
31
|
+
# @return [true]
|
|
32
|
+
#
|
|
33
|
+
def log(level, message, params = {})
|
|
34
|
+
@logger.add(level) { "#{PREFIX} #{fill(message, params)}" }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def fill(message, params)
|
|
40
|
+
message.gsub(PLACEHOLDER) do
|
|
41
|
+
key = Regexp.last_match(1)
|
|
42
|
+
params.fetch(key) { params[key.to_sym] }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree-paypal_merchant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aypex
|
|
@@ -141,6 +141,7 @@ files:
|
|
|
141
141
|
- app/models/spree/paypal_merchant/payment_sources/apple_pay.rb
|
|
142
142
|
- app/models/spree/paypal_merchant/payment_sources/card.rb
|
|
143
143
|
- app/models/spree/paypal_merchant/payment_sources/paypal.rb
|
|
144
|
+
- app/models/spree/paypal_merchant/sdk_logger.rb
|
|
144
145
|
- app/models/spree/paypal_merchant/store_decorator.rb
|
|
145
146
|
- app/presenters/spree/paypal_merchant/order_presenter.rb
|
|
146
147
|
- app/serializers/spree/api/v3/payment_method_serializer_decorator.rb
|