Sha256: 8838ad31b4a83bee5aa81c59d47a847508fe9cb7c2ea3ae27e387a920cfd0c44

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module PayuAPI
  class Order
    class << self
      def get(client:, order_id:)
        request = ApiRequest.new(client: client, method: 'GET', url: "/api/v2_1/orders/#{order_id}")
        GetResponse.new(http_response: request.call)
      end

      def create(client:, params:)
        post_params = params.merge(
          merchantPosId: client.pos_id
        )
        request = ApiRequest.new(client, :POST, '/api/v2_1/orders', post_params)
        CreateResponse.new(http_response: request.call)
      end

      def capture(client:, order_id:)
        params = {
          orderId: order_id,
          orderStatus: 'COMPLETED'
        }
        request = ApiRequest.new(client, :PUT, "/api/v2_1/orders/#{order_id}/status", params)
        Response.new(http_response: request.call)
      end

      def cancel(client:, order_id:)
        request = ApiRequest.new(client, :DELETE, "/api/v2_1/orders/#{order_id}")
        Response.new(http_response: request.call)
      end

      def refund(client:, order_id:, params:)
        post_params = {
          orderId: order_id,
          refund: params
        }
        request = ApiRequest.new(client, :POST, "/api/v2_1/orders/#{order_id}/refunds", post_params)
        RefundResponse.new(http_response: request.call)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
payu_api-0.1.3 lib/payu_api/order.rb
payu_api-0.1.2 lib/payu_api/order.rb
payu_api-0.1.1 lib/payu_api/order.rb