Class: BeyondApi::PaymentMethodDefinitions

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/payment_method_definitions.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods included from Utils

#file_content_type, #handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BeyondApi::Base

Instance Method Details

#all(params = {}) ⇒ OpenStruct

A GET request is used to list all payment method definitions on system level.

$ curl 'https://api-shop.beyondshop.cloud/api/payment-method-definitions' -i -X GET \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@payment_method_definitions = session.payment_method_definitions.all(size: 100, page: 0)

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :paginated (Boolean)
  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)

Scopes:

  • paym:m



81
82
83
# File 'lib/beyond_api/resources/payment_method_definitions.rb', line 81

def all(params = {})
  handle_all_request("/payment-method-definitions", :payment_method_definitions, params)
end

#create(body) ⇒ OpenStruct

A POST request is used to create a payment method definition on system level.

$ curl 'https://system.beyondshop.cloud/api/payment-method-definitions' -i -X POST \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
        "name": "credit-card",
        "referralUriTemplate": "https://example.com/merchants",
        "statusUriTemplate": "https://example.com/merchants/{shopId}/status",
        "disconnectUriTemplate": "https://example.com/merchants/{shopId}/disconnect",
        "createPaymentUriTemplate": "https://example.com/payments",
        "capturePaymentUriTemplate": "https://example.com/payments/{paymentId}/capture",
        "refundPaymentUriTemplate": "https://example.com/payments/{paymentId}/refund",
        "sandbox": "true",
          "workflow": "PAYMENT_ON_BUY",
          "captureWorkflow": "CAPTURE_ON_ORDER",
          "refund": "NO_REFUND",
          "logos": [{
            "setName" : "official",
            "variant" : "STOREFRONT",
            "uri" : "https://example.com/static/storefront.png"
          }],
        "officialName": {"de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
        "en-US" : "Allow your customers to pay by credit card."
        },
          "officialDescription": {
            "de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
            "en-US" : "Allow your customers to pay by credit card."
          },
          "defaultName": {
            "de-DE" : "Kreditkarte",
            "en-US" : "Credit card"
          },
          "defaultDescription": {"de-DE" : "Bezahlen Sie mit Kreditkarte.","en-US" : "Pay by credit card."}}'

Examples:

@payment_method_definitions = session.payment_method_definitions.create(body)

Parameters:

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • paym:m



55
56
57
58
59
60
61
# File 'lib/beyond_api/resources/payment_method_definitions.rb', line 55

def create(body)
  response, status = BeyondApi::Request.post(@session,
                                             "/payment-method-definitions",
                                             body)

  handle_response(response, status)
end

#delete(payment_method_definition_id) ⇒ Object

A DELETE request is used to delete a payment method definition on system level.

$ curl 'https://system.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X DELETE \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

session.payment_method_definitions.delete("credit-card")

Returns:

  • true



174
175
176
177
178
179
180
# File 'lib/beyond_api/resources/payment_method_definitions.rb', line 174

def delete(payment_method_definition_id)
  response, status = BeyondApi::Request.delete(@session,
                                               "/payment-method-definitions/#{payment_method_definition_id}",
                                               body)

  handle_response(response, status, respond_with_true: true)
end

#find(payment_method_definition_id) ⇒ OpenStruct

A GET request is used to deactivate a payment method.

$ curl 'https://api-shop.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X GET \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@payment_method_definition = session.payment_methods.find("credit-card")

Parameters:

  • payment_method_definition_id (String)

    the payment method definition UUID

Returns:

  • (OpenStruct)

Scopes:

  • pymt:u



101
102
103
104
105
106
# File 'lib/beyond_api/resources/payment_method_definitions.rb', line 101

def find(payment_method_definition_id)
  response, status = BeyondApi::Request.get(@session,
                                            "/payment-method-definitions/#{payment_method_definition_id}")

  handle_response(response, status)
end

#update(payment_method_definition_id, body) ⇒ OpenStruct

A PUT request is used to update a payment method definition on system level.

$ curl 'https://system.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X PUT \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
        "name": "credit-card-updated",
        "referralUriTemplate": "https://example.com/merchants",
        "statusUriTemplate": "https://example.com/merchants/{shopId}/status",
        "disconnectUriTemplate": "https://example.com/merchants/{shopId}/disconnect",
        "createPaymentUriTemplate": "https://example.com/payments",
        "capturePaymentUriTemplate": "https://example.com/payments/{paymentId}/capture",
        "refundPaymentUriTemplate": "https://example.com/payments/{paymentId}/refund",
        "workflow": "PAYMENT_ON_SELECTION",
        "captureWorkflow": "CAPTURE_ON_DEMAND",
        "refund": "NO_REFUND",
        "logos": [{
          "setName" : "official",
          "variant" : "STOREFRONT",
          "uri" : "https://example.com/static/storefront.png"
        }],
        "officialName": {"de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
        "en-US" : "Allow your customers to pay by credit card."
        },
        "officialDescription": {
          "de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
          "en-US" : "Allow your customers to pay by credit card."
        },
        "defaultName": {
          "de-DE" : "Kreditkarte",
          "en-US" : "Credit card"
        },
        "defaultDescription": {"de-DE" : "Bezahlen Sie mit Kreditkarte.","en-US" : "Pay by credit card."}}'

Examples:

@payment_method_definition = session.payment_method_definitions.update("credit_card", body)

Parameters:

  • payment_method_definition_id (String)

    the payment method definition UUID

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • paym:m



154
155
156
157
158
159
160
# File 'lib/beyond_api/resources/payment_method_definitions.rb', line 154

def update(payment_method_definition_id, body)
  response, status = BeyondApi::Request.put(@session,
                                            "/payment-method-definitions/#{payment_method_definition_id}",
                                            body)

  handle_response(response, status)
end