Class: Airwallex::PaymentIntent

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::Retrieve
Includes:
APIOperations::Update
Defined in:
lib/airwallex/resources/payment_intent.rb

Constant Summary collapse

SIMULATION_SHOPPER_ACTION_PATH =
"/api/v1/simulation/pa/shopper_actions"

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::List

list

Methods included from APIOperations::Update

included, #save, #update

Methods inherited from APIResource

#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, symbolized_get, symbolized_post, #to_hash, #to_json, #to_s

Constructor Details

This class inherits a constructor from Airwallex::APIResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource

Class Method Details

.resource_pathObject



13
14
15
# File 'lib/airwallex/resources/payment_intent.rb', line 13

def self.resource_path
  "/api/v1/pa/payment_intents"
end

Instance Method Details

#cancel(params = {}) ⇒ Object

Cancel the payment intent



28
29
30
31
32
33
34
35
# File 'lib/airwallex/resources/payment_intent.rb', line 28

def cancel(params = {})
  response = Airwallex.client.post(
    "#{self.class.resource_path}/#{id}/cancel",
    params
  )
  refresh_from(response)
  self
end

#capture(params = {}) ⇒ Object

Capture an authorized payment



38
39
40
41
42
43
44
45
# File 'lib/airwallex/resources/payment_intent.rb', line 38

def capture(params = {})
  response = Airwallex.client.post(
    "#{self.class.resource_path}/#{id}/capture",
    params
  )
  refresh_from(response)
  self
end

#confirm(params = {}) ⇒ Object

Confirm the payment intent with payment method details



18
19
20
21
22
23
24
25
# File 'lib/airwallex/resources/payment_intent.rb', line 18

def confirm(params = {})
  response = Airwallex.client.post(
    "#{self.class.resource_path}/#{id}/confirm",
    params
  )
  refresh_from(response)
  self
end

#simulate_shopper_pay(url:) ⇒ PaymentIntent

Simulate the shopper completing a redirect/3DS challenge raised during #confirm, using the url from the confirm response's next_action

Parameters:

  • url (String)

    the redirect URL from #confirm's next_action

Returns:



52
53
54
55
56
# File 'lib/airwallex/resources/payment_intent.rb', line 52

def simulate_shopper_pay(url:)
  response = Airwallex.client.post("#{SIMULATION_SHOPPER_ACTION_PATH}/pay", url: url)
  refresh_from(response)
  self
end

#simulate_shopper_reject(url:) ⇒ PaymentIntent

Simulate the shopper abandoning/rejecting a redirect/3DS challenge raised during #confirm, using the url from the confirm response's next_action

Parameters:

  • url (String)

    the redirect URL from #confirm's next_action

Returns:



64
65
66
67
68
# File 'lib/airwallex/resources/payment_intent.rb', line 64

def simulate_shopper_reject(url:)
  response = Airwallex.client.post("#{SIMULATION_SHOPPER_ACTION_PATH}/reject", url: url)
  refresh_from(response)
  self
end