Class: IyziPay::Model::Payment

Inherits:
IyziPayResource show all
Defined in:
lib/iyzipay/model/payment.rb

Constant Summary

Constants inherited from IyziPayResource

IyziPayResource::AUTHORIZATION_HEADER_NAME, IyziPayResource::AUTHORIZATION_HEADER_STRING, IyziPayResource::RANDOM_CHARS, IyziPayResource::RANDOM_HEADER_NAME, IyziPayResource::RANDOM_STRING_SIZE

Instance Method Summary collapse

Methods inherited from IyziPayResource

#calculate_hash, #format_header_string, #get_http_header, #get_plain_http_header, #json_decode, #prepare_authorization_string, #random_string, #to_pki_string

Instance Method Details

#create(request = {}, options) ⇒ Object



5
6
7
8
# File 'lib/iyzipay/model/payment.rb', line 5

def create(request = {}, options)
  pki_string = to_pki_string_create(request)
  HttpClient.post("#{options.base_url}/payment/iyzipos/auth/ecom", get_http_header(pki_string, options), request.to_json)
end

#retrieve(request = {}, options) ⇒ Object



10
11
12
13
# File 'lib/iyzipay/model/payment.rb', line 10

def retrieve(request = {}, options)
  pki_string = to_pki_string_retrieve(request)
  HttpClient.post("#{options.base_url}/payment/detail", get_http_header(pki_string, options), request.to_json)
end

#to_pki_string_create(request) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/iyzipay/model/payment.rb', line 15

def to_pki_string_create(request)
  PkiBuilder.new.
      append(:locale, request[:locale]).
      append(:conversationId, request[:conversationId]).
      append_price(:price, request[:price]).
      append_price(:paidPrice, request[:paidPrice]).
      append(:installment, request[:installment]).
      append(:paymentChannel, request[:paymentChannel]).
      append(:basketId, request[:basketId]).
      append(:paymentGroup, request[:paymentGroup]).
      append(:paymentCard, PaymentCard.to_pki_string(request[:paymentCard])).
      append(:buyer, Buyer.to_pki_string(request[:buyer])).
      append(:shippingAddress, Address.to_pki_string(request[:shippingAddress])).
      append(:billingAddress, Address.to_pki_string(request[:billingAddress])).
      append_array(:basketItems, Basket.to_pki_string(request[:basketItems])).
      append(:paymentSource, request[:paymentSource]).
      append(:currency, request[:currency]).
      append(:posOrderId, request[:posOrderId]).
      append(:connectorName, request[:connectorName]).
      get_request_string
end

#to_pki_string_retrieve(request) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/iyzipay/model/payment.rb', line 37

def to_pki_string_retrieve(request)
  PkiBuilder.new.
      append(:locale, request[:locale]).
      append(:conversationId, request[:conversationId]).
      append(:paymentId, request[:paymentId]).
      append(:paymentConversationId, request[:paymentConversationId]).
      get_request_string
end