Module: PaymentGateway

Included in:
TessituraRest
Defined in:
lib/tessitura_rest/payment_gateway/payment_gateway.rb

Instance Method Summary collapse

Instance Method Details

#authorize_payment(amount, store_card, payload, payment_id, return_url, constituent, shopper_ip, address, delivery_date, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tessitura_rest/payment_gateway/payment_gateway.rb', line 2

def authorize_payment(amount, store_card, payload, payment_id, return_url, constituent, shopper_ip, address, delivery_date, options = {})
  parameters = {
    'Amount': amount,
    'StoreAccount': store_card,
    'Card': {
      'TessituraMerchantServicesData': payload,
    },
    'PaymentId': payment_id,
    'ConstituentId': constituent.customer_no,
    'TransactionOrigin': 'webapi',
    'PaymentMethodId': 606,
    'ReturnUrl': return_url,
    'IsECommerce': true,
    'ShopperIp': shopper_ip,
    'ShopperEmail': constituent.email,
    'ShopperName': {
      'FirstName': constituent.first_name,
      'LastName': constituent.last_name,
    },
    'BillingAddress': {
      'PostalCode': address.postal_code,
      'Street1': address.street1,
      'AddressId': address.id,
      'Country': address.country_iso2_code,
    },
    'DeliveryDate': delivery_date,
  }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters.to_json)
  self.class.post(base_api_endpoint('PaymentGateway/Authorization/Authorize'), options)
end

#finalize_payment(payload, payment_id, store_account, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/tessitura_rest/payment_gateway/payment_gateway.rb', line 53

def finalize_payment(payload, payment_id, , options = {})
  parameters = {
    'PaymentId': payment_id,
    'RedirectResult': payload,
    'StoreAccount': ,
  }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters.to_json)
  self.class.post(base_api_endpoint('PaymentGateway/Authorization/Finalize'), options)
end

#reversal_request(amount, reference_number, payment_id, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/tessitura_rest/payment_gateway/payment_gateway.rb', line 64

def reversal_request(amount, reference_number, payment_id, options = {})
  parameters = {
    'Amount': amount,
    'PaymentId': payment_id,
    'TransactionOrigin': 'webapi',
    'PaymentMethodId': 606,
  }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters.to_json)
  self.class.post(base_api_endpoint("PaymentGateway/Authorization/#{reference_number}/Reverse"), options)
end

#store_card(amount, payment_id, constituent_id, payload, return_url, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tessitura_rest/payment_gateway/payment_gateway.rb', line 34

def store_card(amount, payment_id, constituent_id, payload, return_url, options = {})
  parameters = {
    'Amount': amount,
    'PaymentId': payment_id,
    'ConstituentId': constituent_id,
    'Card': {
      'TessituraMerchantServicesData': payload,
    },
    'TransactionOrigin': 'webapi',
    'PaymentMethodId': 606,
    'IsECommerce': true,
    'StoreAccount': true,
    'ReturnUrl': return_url,
  }
  options.merge!(basic_auth: @auth, headers: @headers)
  options.merge!(:body => parameters.to_json)
  self.class.post(base_api_endpoint('PaymentGateway/Authorization/Authorize'), options)
end