Class: FacebookCommerce::CancellationRefundApi

Inherits:
Api
  • Object
show all
Defined in:
lib/facebook_commerce.rb

Instance Attribute Summary

Attributes inherited from Api

#access_token, #cms_id, #logger

Instance Method Summary collapse

Methods inherited from Api

#initialize

Constructor Details

This class inherits a constructor from FacebookCommerce::Api

Instance Method Details

#cancel_order(order_id) ⇒ Hash

Returns Cancellation response, eg. { success: true}.

Parameters:

  • order_id (String)

    Facebook order ID

Returns:

  • (Hash)

    Cancellation response, eg. { success: true}



146
147
148
149
# File 'lib/facebook_commerce.rb', line 146

def cancel_order(order_id)
  data = { idempotency_key: SecureRandom.uuid }
  post("#{order_id}/cancellations", data)
end

#refund_order(order_id, reason_code, items = nil) ⇒ Hash

Returns Refund response, eg. { success: true}.

Parameters:

  • order_id (String)

    Facebook order ID

  • reason_code (String)

    Reason code for the refund, eg. ‘REFUND_REASON_OTHER’

  • items (Array<Hash>) (defaults to: nil)

    Item hashes (retailer_id|product_id, quantity), required if partial refund

Returns:

  • (Hash)

    Refund response, eg. { success: true}



155
156
157
158
# File 'lib/facebook_commerce.rb', line 155

def refund_order(order_id, reason_code, items = nil)
  data = { reason_code: reason_code, idempotency_key: SecureRandom.uuid }
  post("#{order_id}/refunds", data)
end