Sha256: b10902204067b6f20e59f34a02d70bfc2643eaf3201538e6840406308cbfdc3f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
payu_api-0.1.0 lib/payu_api/order.rb