class PandaPay::Donation
Attributes
charge_amount[R]
created[R]
currency[R]
customer[R]
destination[R]
donation_after_fees[R]
grants[R]
id[R]
livemode[R]
object[R]
payment_token[R]
platform_fee[R]
receipt_email[R]
restriction[R]
Public Class Methods
create(amount: , destination: "", restriction: "", source: , receipt_email: , platform_fee: "0", currency: "USD")
click to toggle source
# 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
new(attributes)
click to toggle source
# 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