Class: Workarea::Afterpay::BogusGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/workarea/afterpay/bogus_gateway.rb

Instance Method Summary collapse

Constructor Details

#initializeBogusGateway

Returns a new instance of BogusGateway.



4
5
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 4

def initialize(*)
end

Instance Method Details

#authorize(token, order_id = "", request_id) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 102

def authorize(token, order_id = "", request_id)
  if token == "error_token"
    Response.new(response(capture_error_response_body, 402))
  elsif token == "timeout_token"
    Response.new(response(nil, 502))
  elsif token == 'declined'
    Response.new(response(payment_response_body(status: 'DECLINED'), 200))
  else
    Response.new(response(payment_response_body, 200))
  end
end

#capture(payment_id, amount, request_id) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 94

def capture(payment_id, amount, request_id)
  if payment_id == 'declined'
    Response.new(response(payment_response_body(status: 'DECLINED'), 200))
  else
    Response.new(response(payment_response_body, 200))
  end
end

#create_order(order) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 85

def create_order(order)
  b = {
    "token": "q54l9qd907m6iqqqlcrm5tpbjjsnfo47vsm59gqrfnd2rqefk9hu",
    "expires": "2016-05-10T13:14:01Z"
  }

  Response.new(response(b))
end

#get_configurationObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 7

def get_configuration
  b = {
      "minimumAmount": {
           "amount": "5.00",
           "currency": "USD"
       },
      "maximumAmount": {
          "amount": "500.00",
          "currency": "USD"
      }
    }

  Response.new(response(b))
end

#get_order(token, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 22

def get_order(token, options = {})
  b = {
        "billing": {
            "countryCode": "US",
            "line1": "29 fort mott road",
            "name": "Jeffrey Yucis",
            "phoneNumber": "3027507743",
            "postcode": "08070",
            "state": "NJ",
            "suburb": "pennsville"
        },
        "consumer": {
            "email": "[email protected]",
            "givenNames": "Jeffrey",
            "phoneNumber": "3027507743",
            "surname": "Yucis"
        },
        "courier": {},
        "discounts": [],
        "expires": "2019-04-02T16:52:43.920Z",
        "items": [
            {
                "name": "Small Wool Coat",
                "price": {
                    "amount": "89.30",
                    "currency": "USD"
                },
                "quantity": 1,
                "sku": "139364945-9"
            }
        ],
        "merchant": {
            "redirectCancelUrl": "http://localhost:3000/afterpay/cancel",
            "redirectConfirmUrl": "http://localhost:3000/afterpay/complete"
        },
        "merchantReference": "63837A272F",
        "paymentType": "PAY_BY_INSTALLMENT",
        "shipping": {
            "countryCode": "US",
            "line1": "29 fort mott road",
            "name": "Jeffrey Yucis",
            "phoneNumber": "3027507743",
            "postcode": "08070",
            "state": "NJ",
            "suburb": "pennsville"
        },
        "shippingAmount": {
            "amount": "6.00",
            "currency": "USD"
        },
        "taxAmount": {
            "amount": "0.00",
            "currency": "USD"
        },
        "token": "9tlqhfgebl6mu2g9t98rre2ia25ri2hvadc4aaimvpca1p9fma5j",
        "amount": {
            "amount": "95.30",
            "currency": "USD"
        }
    }
  Response.new(response(b))
end

#purchase(token, order_id = "", request_id) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 114

def purchase(token, order_id = "", request_id)
  if token == "error_token"
    Response.new(response(capture_error_response_body, 402))
  elsif token == 'declined'
    Response.new(response(payment_response_body(status: 'DECLINED'), 200))
  else
    Response.new(response(payment_response_body, 200))
  end
end

#refund(afterpay_order_id, amount, request_id) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 124

def refund(afterpay_order_id, amount, request_id)
  b = {
    "requestId": "61cdad2d-8e10-42ec-a97b-8712dd7a8ca9",
    "amount": {
        "amount": "10.00",
        "currency": "USD"
    },
    "merchantReference": "RF127261AD22",
    "refundId": "56785678",
    "refundedAt": "2015-07-10T15:01:14.123Z"
  }

  Response.new(response(b))
end

#void(payment_id) ⇒ Object



139
140
141
# File 'lib/workarea/afterpay/bogus_gateway.rb', line 139

def void(payment_id)
  Response.new(response(payment_response_body))
end