Class: ShieldPay::Customer

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/shieldpay/customer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

stringify_keys, stringify_keys!

Instance Attribute Details

#customer_keyObject

Returns the value of attribute customer_key.



5
6
7
# File 'lib/shieldpay/customer.rb', line 5

def customer_key
  @customer_key
end

#display_nameObject

Returns the value of attribute display_name.



5
6
7
# File 'lib/shieldpay/customer.rb', line 5

def display_name
  @display_name
end

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/shieldpay/customer.rb', line 5

def email
  @email
end

#kyc_verifiedObject

Returns the value of attribute kyc_verified.



5
6
7
# File 'lib/shieldpay/customer.rb', line 5

def kyc_verified
  @kyc_verified
end

#mobile_noObject

Returns the value of attribute mobile_no.



5
6
7
# File 'lib/shieldpay/customer.rb', line 5

def mobile_no
  @mobile_no
end

Class Method Details

.create(params = {}) ⇒ Object

Contact Params Parameter Optional? Description display_name no The customer’s name email no Email address for contact person mobile_no no This customer’s mobile number



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shieldpay/customer.rb', line 13

def self.create(params={})
  stringify_keys!(params)
  response = Request.new.post("/Customer/CreateRegisterCustomer", params)

  customer_key = response["Data"].dig("CustomerKey")
  kyc_verified = response["Data"].dig("KYCStatus") == "Verified"
  new.tap do |c|
    c.customer_key = customer_key
    c.kyc_verified = kyc_verified
    c.display_name = params["display_name"]
    c.email = params["email"]
    c.mobile_no = params["mobile_no"]
  end
end

.kyc_verify(params = {}) ⇒ Object

Verification Params Parameter title first_name last_name gender date_of_birth flat_number building_number street state town postcode country customer_key



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/shieldpay/customer.rb', line 44

def self.kyc_verify(params={})
  stringify_keys!(params)
  if params["customer_key"].strip.empty?
    raise ShieldPay::Errors::RequiredField.new("customer_key field is required to verify this customer. You can create a customer_key field using the Customer.create method")
  end
  params["gender"] = params.delete("gender").to_s.upcase
  params["date_of_birth"] = Date.parse(params["date_of_birth"].to_s).to_s
  response = Request.new.post("/Customer/KYCVerification", params)
  kyc_verified = response["Data"].dig("AddressVerified")
  new.tap do |c|
    c.kyc_verified = kyc_verified
  end
end

Instance Method Details

#kyc_verified?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/shieldpay/customer.rb', line 58

def kyc_verified?
  @kyc_verified
end