Class: PandaPay::Donation
- Inherits:
-
Object
- Object
- PandaPay::Donation
- Defined in:
- lib/pandapay/donation.rb
Instance Attribute Summary collapse
-
#charge_amount ⇒ Object
readonly
Returns the value of attribute charge_amount.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#donation_after_fees ⇒ Object
readonly
Returns the value of attribute donation_after_fees.
-
#grants ⇒ Object
readonly
Returns the value of attribute grants.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#livemode ⇒ Object
readonly
Returns the value of attribute livemode.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#payment_token ⇒ Object
readonly
Returns the value of attribute payment_token.
-
#platform_fee ⇒ Object
readonly
Returns the value of attribute platform_fee.
-
#receipt_email ⇒ Object
readonly
Returns the value of attribute receipt_email.
-
#restriction ⇒ Object
readonly
Returns the value of attribute restriction.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Donation
constructor
A new instance of Donation.
Constructor Details
#initialize(attributes) ⇒ Donation
Returns a new instance of Donation.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pandapay/donation.rb', line 5 def initialize(attributes) @id = attributes["id"] @object = attributes["object"] @created = attributes["created"] @livemode = attributes["livemode"] @charge_amount = attributes["charge_amount"] @platform_fee = attributes["platform_fee"] @donation_after_fees = attributes["donation_after_fees"] @currency = attributes["currency"] @payment_token = attributes["payment_token"] @customer = attributes["customer"] @grants = attributes["grants"] @receipt_email = attributes["receipt_email"] @destination = attributes["destination"] @restriction = attributes["restriction"] end |
Instance Attribute Details
#charge_amount ⇒ Object (readonly)
Returns the value of attribute charge_amount.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def charge_amount @charge_amount end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def created @created end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def currency @currency end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def customer @customer end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def destination @destination end |
#donation_after_fees ⇒ Object (readonly)
Returns the value of attribute donation_after_fees.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def donation_after_fees @donation_after_fees end |
#grants ⇒ Object (readonly)
Returns the value of attribute grants.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def grants @grants end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def id @id end |
#livemode ⇒ Object (readonly)
Returns the value of attribute livemode.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def livemode @livemode end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def object @object end |
#payment_token ⇒ Object (readonly)
Returns the value of attribute payment_token.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def payment_token @payment_token end |
#platform_fee ⇒ Object (readonly)
Returns the value of attribute platform_fee.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def platform_fee @platform_fee end |
#receipt_email ⇒ Object (readonly)
Returns the value of attribute receipt_email.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def receipt_email @receipt_email end |
#restriction ⇒ Object (readonly)
Returns the value of attribute restriction.
3 4 5 |
# File 'lib/pandapay/donation.rb', line 3 def restriction @restriction end |
Class Method Details
.create(amount:, destination: "", restriction: "", source:, receipt_email:, platform_fee: "0", currency: "USD") ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pandapay/donation.rb', line 22 def self.create(amount: , destination: "", restriction: "", source: , receipt_email: , platform_fee: "0", currency: "USD") conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}") response = conn.post '/v1/donations', { :amount => amount, :currency => currency, :source => source, :receipt_email => receipt_email, :platform_fee => platform_fee, :destination => destination, :restriction => restriction } attributes = JSON.parse(response.body) if attributes.has_key? "error" or attributes.has_key? "errors" raise response.body else new(attributes) end end |