module Simpal::API::Orders

@see developer.paypal.com/docs/api/orders/v2/

Public Class Methods

authorize(id, params = {}, headers: {}, client: nil) click to toggle source

Authorize the payment for an order.

@param id [String] The ID of an existing order. @param params [Hash] The parameters for the authorize request. @param headers [Hash] The custom headers to add to the request. @param client [Simpal::Client] The API client to make the request with. @return [Hash] A Hash representing the order.

# File lib/simpal/api/orders.rb, line 56
def self.authorize(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/checkout/orders/#{id}/authorize", params, headers)
  response.body
end
capture(id, params = {}, headers: {}, client: nil) click to toggle source

Capture the payment for an order.

@param id [String] The ID of an existing order. @param params [Hash] The parameters for the capture request. @param headers [Hash] The custom headers to add to the request. @param client [Simpal::Client] The API client to make the request with. @return [Hash] A Hash representing the order.

# File lib/simpal/api/orders.rb, line 70
def self.capture(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/checkout/orders/#{id}/capture", params, headers)
  response.body
end
create(params = {}, headers: {}, client: nil) click to toggle source

Create an order.

@param params [Hash] The parameters for the create request. @param headers [Hash] The custom headers to add to the request. @param client [Simpal::Client] The API client to make the request with. @return [Hash] A Hash representing the order.

# File lib/simpal/api/orders.rb, line 15
def self.create(params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post('/v2/checkout/orders', params, headers)
  response.body
end
retrieve(id, headers: {}, client: nil) click to toggle source

Retrieve an order.

@param id [String] The ID of an existing order. @param headers [Hash] The custom headers to add to the request. @param client [Simpal::Client] The API client to make the request with. @return [Hash] A Hash representing the order.

# File lib/simpal/api/orders.rb, line 42
def self.retrieve(id, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.get("/v2/checkout/orders/#{id}", headers)
  response.body
end
update(id, params = [], headers: {}, client: nil) click to toggle source

Update an order.

@param id [String] The ID of an existing order. @param params [Array<Hash>] The collection of patches to apply to the order. @param headers [Hash] The custom headers to add to the request. @param client [Simpal::Client] The API client to make the request with. @return [Hash] An empty hash.

# File lib/simpal/api/orders.rb, line 29
def self.update(id, params = [], headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.patch("/v2/checkout/orders/#{id}", params, headers)
  response.body
end