Class: Paypal::REST

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal/rest.rb,
lib/paypal/rest/version.rb,
lib/paypal/rest/connection.rb,
lib/paypal/rest/bearer_token.rb

Defined Under Namespace

Classes: BearerToken, ClientError, Connection

Constant Summary collapse

VERSION =
"1.1.1".freeze

Class Method Summary collapse

Class Method Details

.capture_payment_for_order(order_id, full_response: false) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/paypal/rest.rb', line 32

def capture_payment_for_order(order_id, full_response: false)
  if full_response
    post("/v2/checkout/orders/#{order_id}/capture", headers: {
      Prefer: "return=representation",
    }) # rubocop:disable Style/TrailingCommaInArguments, Layout/MultilineMethodCallBraceLayout
  else
    post("/v2/checkout/orders/#{order_id}/capture")
  end
end

.clear_configurationObject



18
19
20
# File 'lib/paypal/rest.rb', line 18

def clear_configuration
  @configuration = nil
end

.configurationObject



14
15
16
# File 'lib/paypal/rest.rb', line 14

def configuration
  @configuration ||= RESTConfiguration.new
end

.configure(&block) ⇒ Object



10
11
12
# File 'lib/paypal/rest.rb', line 10

def configure(&block)
  block.call(configuration)
end

.create_order(full_response: false, **params) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/paypal/rest.rb', line 22

def create_order(full_response: false, **params)
  if full_response
    post("/v2/checkout/orders", params:, headers: {
      Prefer: "return=representation",
    }) # rubocop:disable Style/TrailingCommaInArguments, Layout/MultilineMethodCallBraceLayout
  else
    post("/v2/checkout/orders", params:)[:id]
  end
end

.reset_connectionObject



42
43
44
45
# File 'lib/paypal/rest.rb', line 42

def reset_connection
  @connection = nil
  @bearer_token = nil
end