Module: Propay
- Defined in:
- lib/propay.rb,
lib/modules/fib.rb,
lib/propay/version.rb,
lib/generators/propay/install_generator.rb
Defined Under Namespace
Modules: Fixnum, Generators Classes: ResponseError
Constant Summary collapse
- CARD_TYPES =
%w(Visa MasterCard AMEX Discover DinersClub JCB)
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.add_payment_method(options = {}) ⇒ Object
:name :card_number :address :address2 :country :state :zip :description :expiration :payer_id :card_type.
-
.authorize_payment(options = {}) ⇒ Object
:payment_method_id :amount :comment :comment2 :merchant_profile_id :payer_id || :user_id.
-
.capture_payment(options = {}) ⇒ Object
:amount :comment :comment2 :merchant_profile_id :transaction_id :payer_id || :user_id.
- .configure {|configuration| ... } ⇒ Object
- .create_merchant_profile(options = {}) ⇒ Object
- .create_payer(options = {}) ⇒ Object
-
.delete_payment_method(options = {}) ⇒ Object
:payment_method_id :user_id || :payer_id.
- .find_or_create_payer(options = {}) ⇒ Object
- .get_temp_token(options = {}) ⇒ Object
-
.list_payment_methods(options = {}) ⇒ Object
:user_id || payer_id.
-
.process_payment(options = {}) ⇒ Object
:payment_method_id :amount :comment :comment2 :merchant_profile_id :payer_id || :user_id.
-
.refund_payment(options = {}) ⇒ Object
:amount, :transaction_id, :merchant_profile_id.
-
.void_payment(options = {}) ⇒ Object
:transaction_id, :merchant_profile_id.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/propay.rb', line 12 def configuration @configuration end |
Class Method Details
.add_payment_method(options = {}) ⇒ Object
:name :card_number :address :address2 :country :state :zip :description :expiration :payer_id :card_type
36 37 38 |
# File 'lib/propay.rb', line 36 def add_payment_method( = {}) soap_action("CreatePaymentMethod", .merge(:payer_id => ([:payer_id] || find_or_create_payer()))) end |
.authorize_payment(options = {}) ⇒ Object
:payment_method_id :amount :comment :comment2 :merchant_profile_id :payer_id || :user_id
57 58 59 |
# File 'lib/propay.rb', line 57 def ( = {}) soap_action("AuthorizePaymentMethodTransaction", .merge(:payer_id => ([:payer_id] || find_or_create_payer())))["AuthorizePaymentMethodTransactionResponse"]["AuthorizePaymentMethodTransactionResult"] end |
.capture_payment(options = {}) ⇒ Object
:amount :comment :comment2 :merchant_profile_id :transaction_id :payer_id || :user_id
62 63 64 |
# File 'lib/propay.rb', line 62 def capture_payment( = {}) soap_action("CapturePayment", .merge(:payer_id => ([:payer_id] || find_or_create_payer())))["CapturePaymentResponse"]["CapturePaymentResult"] end |
.configure {|configuration| ... } ⇒ Object
14 15 16 17 18 19 |
# File 'lib/propay.rb', line 14 def configure self.configuration ||= OpenStruct.new yield(configuration) current_path = File.(File.dirname(__FILE__)) Dir["#{current_path}/modules/*.rb"].each {|file| require file } end |
.create_merchant_profile(options = {}) ⇒ Object
21 22 23 |
# File 'lib/propay.rb', line 21 def create_merchant_profile( = {}) soap_action("CreateMerchantProfile", ) end |
.create_payer(options = {}) ⇒ Object
31 32 33 |
# File 'lib/propay.rb', line 31 def create_payer( = {}) payer_id = soap_action("CreatePayerWithData", )["CreatePayerWithDataResponse"]["CreatePayerWithDataResult"]["ExternalAccountID"] unless payer_id end |
.delete_payment_method(options = {}) ⇒ Object
:payment_method_id :user_id || :payer_id
41 42 43 |
# File 'lib/propay.rb', line 41 def delete_payment_method( = {}) soap_action("DeletePaymentMethod", .merge(:payer_id => ([:payer_id] || find_or_create_payer()))) end |
.find_or_create_payer(options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/propay.rb', line 25 def find_or_create_payer( = {}) payer_id = soap_action("GetPayers", )["GetPayersResponse"]["GetPayersResult"]["Payers"]["PayerInfo"].first["payerAccountId"] rescue false payer_id = soap_action("CreatePayerWithData", )["CreatePayerWithDataResponse"]["CreatePayerWithDataResult"]["ExternalAccountID"] unless payer_id return payer_id end |
.get_temp_token(options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/propay.rb', line 76 def get_temp_token( = {}) result = soap_action('GetTempToken', ) raise result["GetTempTokenResponse"]["GetTempTokenResult"]["RequestResult"]["ResultMessage"] if result["GetTempTokenResponse"]["GetTempTokenResult"]["RequestResult"]["ResultValue"] == "FAILURE" result end |
.list_payment_methods(options = {}) ⇒ Object
:user_id || payer_id
46 47 48 49 |
# File 'lib/propay.rb', line 46 def list_payment_methods( = {}) response = soap_action("GetAllPayerPaymentMethods", .merge(:payer_id => ([:payer_id] || find_or_create_payer())))["GetAllPayerPaymentMethodsResponse"]["GetAllPayerPaymentMethodsResult"]["PaymentMethods"]["PaymentMethodInformation"] rescue nil return response.class == Hash ? [response] : response end |
.process_payment(options = {}) ⇒ Object
:payment_method_id :amount :comment :comment2 :merchant_profile_id :payer_id || :user_id
52 53 54 |
# File 'lib/propay.rb', line 52 def process_payment( = {}) soap_action("ProcessPaymentMethodTransaction", .merge(:payer_id => ([:payer_id] || find_or_create_payer())))["ProcessPaymentMethodTransactionResponse"]["ProcessPaymentMethodTransactionResult"] end |
.refund_payment(options = {}) ⇒ Object
:amount, :transaction_id, :merchant_profile_id
72 73 74 |
# File 'lib/propay.rb', line 72 def refund_payment( = {}) soap_action("RefundPaymentV2", )["RefundPaymentV2Response"]["RefundPaymentV2Result"] end |
.void_payment(options = {}) ⇒ Object
:transaction_id, :merchant_profile_id
67 68 69 |
# File 'lib/propay.rb', line 67 def void_payment( = {}) soap_action("VoidPaymentV2", )["VoidPaymentV2Response"]["VoidPaymentV2Result"] end |