paypal-payment 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Guardfile +24 -0
- data/README.rdoc +107 -0
- data/Rakefile +5 -0
- data/docs/AdaptivePayments.rdoc +84 -0
- data/docs/PP_NVPAPI_DeveloperGuide.pdf +0 -0
- data/docs/PP_WPP_IntegrationGuide.pdf +0 -0
- data/docs/adaptive_payments.md +55 -0
- data/docs/api.txt +67 -0
- data/docs/design.txt +38 -0
- data/docs/express_checkout.md +172 -0
- data/docs/requirements.txt +32 -0
- data/lib/paypal-payment.rb +10 -0
- data/lib/paypal/adaptive_payments.rb +31 -0
- data/lib/paypal/adaptive_payments/api.rb +51 -0
- data/lib/paypal/adaptive_payments/base.rb +11 -0
- data/lib/paypal/adaptive_payments/client_details.rb +14 -0
- data/lib/paypal/adaptive_payments/display_options.rb +10 -0
- data/lib/paypal/adaptive_payments/funding_constraint.rb +11 -0
- data/lib/paypal/adaptive_payments/funding_type_info.rb +8 -0
- data/lib/paypal/adaptive_payments/funding_type_list.rb +11 -0
- data/lib/paypal/adaptive_payments/initiating_entity.rb +11 -0
- data/lib/paypal/adaptive_payments/institution_customer.rb +13 -0
- data/lib/paypal/adaptive_payments/invoice_data.rb +13 -0
- data/lib/paypal/adaptive_payments/invoice_item.rb +11 -0
- data/lib/paypal/adaptive_payments/payment.rb +105 -0
- data/lib/paypal/adaptive_payments/payment_info.rb +18 -0
- data/lib/paypal/adaptive_payments/payment_info_list.rb +11 -0
- data/lib/paypal/adaptive_payments/payment_options.rb +39 -0
- data/lib/paypal/adaptive_payments/phone.rb +9 -0
- data/lib/paypal/adaptive_payments/preapproval.rb +52 -0
- data/lib/paypal/adaptive_payments/receiver.rb +17 -0
- data/lib/paypal/adaptive_payments/receiver_list.rb +49 -0
- data/lib/paypal/adaptive_payments/receiver_options.rb +19 -0
- data/lib/paypal/adaptive_payments/request.rb +51 -0
- data/lib/paypal/adaptive_payments/response.rb +38 -0
- data/lib/paypal/adaptive_payments/response/address.rb +13 -0
- data/lib/paypal/adaptive_payments/response/address_list.rb +11 -0
- data/lib/paypal/adaptive_payments/response/base_address.rb +13 -0
- data/lib/paypal/adaptive_payments/response/details.rb +19 -0
- data/lib/paypal/adaptive_payments/response/error_list.rb +15 -0
- data/lib/paypal/adaptive_payments/response/pay.rb +31 -0
- data/lib/paypal/adaptive_payments/response/pay_error.rb +16 -0
- data/lib/paypal/adaptive_payments/response/pay_error_list.rb +15 -0
- data/lib/paypal/adaptive_payments/response/pay_options.rb +7 -0
- data/lib/paypal/adaptive_payments/response/preapproval.rb +47 -0
- data/lib/paypal/adaptive_payments/response/refund.rb +16 -0
- data/lib/paypal/adaptive_payments/response/refund_info.rb +24 -0
- data/lib/paypal/adaptive_payments/response/refund_info_list.rb +11 -0
- data/lib/paypal/adaptive_payments/response/shipping_address.rb +11 -0
- data/lib/paypal/adaptive_payments/sender_identifier.rb +7 -0
- data/lib/paypal/adaptive_payments/sender_options.rb +8 -0
- data/lib/paypal/api.rb +94 -0
- data/lib/paypal/cacert.pem +3987 -0
- data/lib/paypal/common.rb +11 -0
- data/lib/paypal/common/base.rb +83 -0
- data/lib/paypal/common/error_data.rb +15 -0
- data/lib/paypal/common/request.rb +45 -0
- data/lib/paypal/common/request_envelope.rb +13 -0
- data/lib/paypal/common/response.rb +34 -0
- data/lib/paypal/common/response_envelope.rb +19 -0
- data/lib/paypal/express_checkout.rb +19 -0
- data/lib/paypal/express_checkout/account.rb +16 -0
- data/lib/paypal/express_checkout/api.rb +43 -0
- data/lib/paypal/express_checkout/base.rb +37 -0
- data/lib/paypal/express_checkout/billing.rb +7 -0
- data/lib/paypal/express_checkout/callback.rb +17 -0
- data/lib/paypal/express_checkout/checkout.rb +144 -0
- data/lib/paypal/express_checkout/fields.rb +449 -0
- data/lib/paypal/express_checkout/fmf.rb +7 -0
- data/lib/paypal/express_checkout/payment.rb +76 -0
- data/lib/paypal/express_checkout/payment_item.rb +7 -0
- data/lib/paypal/express_checkout/recurring.rb +131 -0
- data/lib/paypal/express_checkout/request.rb +212 -0
- data/lib/paypal/express_checkout/response.rb +52 -0
- data/lib/paypal/express_checkout/response/account.rb +30 -0
- data/lib/paypal/express_checkout/response/address.rb +29 -0
- data/lib/paypal/express_checkout/response/authorization.rb +25 -0
- data/lib/paypal/express_checkout/response/base.rb +125 -0
- data/lib/paypal/express_checkout/response/callback_request.rb +10 -0
- data/lib/paypal/express_checkout/response/callback_response.rb +8 -0
- data/lib/paypal/express_checkout/response/capture.rb +14 -0
- data/lib/paypal/express_checkout/response/checkout.rb +11 -0
- data/lib/paypal/express_checkout/response/details.rb +35 -0
- data/lib/paypal/express_checkout/response/manage_profile.rb +9 -0
- data/lib/paypal/express_checkout/response/notification.rb +85 -0
- data/lib/paypal/express_checkout/response/payment.rb +24 -0
- data/lib/paypal/express_checkout/response/profile.rb +58 -0
- data/lib/paypal/express_checkout/response/reference.rb +11 -0
- data/lib/paypal/express_checkout/response/refund.rb +13 -0
- data/lib/paypal/express_checkout/response/search.rb +33 -0
- data/lib/paypal/express_checkout/response/transaction_details.rb +11 -0
- data/lib/paypal/express_checkout/shipping_option.rb +7 -0
- data/lib/paypal/express_checkout/utils.rb +26 -0
- data/lib/paypal/express_checkout/version.rb +10 -0
- data/lib/paypal/invoice.rb +22 -0
- data/lib/paypal/invoice/api.rb +51 -0
- data/lib/paypal/invoice/base.rb +11 -0
- data/lib/paypal/invoice/base_address.rb +11 -0
- data/lib/paypal/invoice/business_info.rb +17 -0
- data/lib/paypal/invoice/date_range.rb +8 -0
- data/lib/paypal/invoice/invoice.rb +117 -0
- data/lib/paypal/invoice/invoice_details.rb +38 -0
- data/lib/paypal/invoice/invoice_item.rb +13 -0
- data/lib/paypal/invoice/invoice_item_list.rb +10 -0
- data/lib/paypal/invoice/invoice_summary.rb +22 -0
- data/lib/paypal/invoice/invoice_summary_list.rb +10 -0
- data/lib/paypal/invoice/other_payment_details.rb +13 -0
- data/lib/paypal/invoice/payment_details.rb +16 -0
- data/lib/paypal/invoice/paypal_payment_details.rb +11 -0
- data/lib/paypal/invoice/request.rb +43 -0
- data/lib/paypal/invoice/response.rb +27 -0
- data/lib/paypal/invoice/response/details.rb +23 -0
- data/lib/paypal/invoice/response/invoice.rb +10 -0
- data/lib/paypal/invoice/response/search.rb +15 -0
- data/lib/paypal/invoice/search.rb +19 -0
- data/lib/paypal/invoice/search_parameters.rb +20 -0
- data/lib/paypal/permissions.rb +12 -0
- data/lib/paypal/permissions/api.rb +60 -0
- data/lib/paypal/permissions/base.rb +11 -0
- data/lib/paypal/permissions/permission.rb +33 -0
- data/lib/paypal/permissions/personal_data.rb +17 -0
- data/lib/paypal/permissions/request.rb +52 -0
- data/lib/paypal/permissions/response.rb +24 -0
- data/lib/paypal/permissions/response/permission.rb +14 -0
- data/lib/paypal/permissions/response/personal_data.rb +8 -0
- data/lib/paypal/permissions/response/token.rb +10 -0
- data/lib/paypal/permissions/token.rb +13 -0
- data/lib/paypal/recurring.rb +110 -0
- data/lib/paypal/request.rb +82 -0
- data/lib/paypal/version.rb +8 -0
- data/paypal-payment.gemspec +30 -0
- data/spec/fixtures/adaptive_payments/payment/create/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/create/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/details/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/payment/pay/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/pay/preapproval.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/pay/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/pay/with_pay_key.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/refund/failure.yml +62 -0
- data/spec/fixtures/adaptive_payments/payment/refund/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/payment/shipping_addresses/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/payment_options/get/success.yml +174 -0
- data/spec/fixtures/adaptive_payments/payment_options/set/success.yml +113 -0
- data/spec/fixtures/adaptive_payments/preapproval/create/success.yml +58 -0
- data/spec/fixtures/adaptive_payments/preapproval/details/success.yml +168 -0
- data/spec/fixtures/express_checkout/account/balance/success.yml +32 -0
- data/spec/fixtures/express_checkout/account/pal_details/success.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/checkout/sales/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/checkout/success.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/details/failure.yml +32 -0
- data/spec/fixtures/express_checkout/checkout/details/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/pay/sales/success.yml +61 -0
- data/spec/fixtures/express_checkout/checkout/pay/success.yml +61 -0
- data/spec/fixtures/express_checkout/payment/details/failure.yml +32 -0
- data/spec/fixtures/express_checkout/payment/details/success.yml +32 -0
- data/spec/fixtures/express_checkout/payment/refund/failure.yml +32 -0
- data/spec/fixtures/express_checkout/payment/refund/success.yml +32 -0
- data/spec/fixtures/express_checkout/payment/search/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/cancel/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/cancel/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/checkout/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/create_profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/create_profile/success.yml +61 -0
- data/spec/fixtures/express_checkout/recurring/profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/profile/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/reactivate/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/reactivate/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/suspend/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/suspend/success.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/failure.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/profile.yml +32 -0
- data/spec/fixtures/express_checkout/recurring/update_profile/success.yml +32 -0
- data/spec/fixtures/invoice/cancel/success.yml +174 -0
- data/spec/fixtures/invoice/create/failure.yml +62 -0
- data/spec/fixtures/invoice/create/success.yml +60 -0
- data/spec/fixtures/invoice/create_and_send/failure.yml +62 -0
- data/spec/fixtures/invoice/create_and_send/success.yml +60 -0
- data/spec/fixtures/invoice/details/success.yml +117 -0
- data/spec/fixtures/invoice/mark_as_paid/failure.yml +180 -0
- data/spec/fixtures/invoice/mark_as_paid/success.yml +174 -0
- data/spec/fixtures/invoice/mark_as_refunded/success.yml +174 -0
- data/spec/fixtures/invoice/mark_as_unpaid/success.yml +231 -0
- data/spec/fixtures/invoice/search/success.yml +174 -0
- data/spec/fixtures/invoice/send/success.yml +117 -0
- data/spec/fixtures/invoice/update/failure.yml +119 -0
- data/spec/fixtures/invoice/update/success.yml +117 -0
- data/spec/fixtures/ipn/express_checkout.json +35 -0
- data/spec/fixtures/ipn/recurring_payment.json +44 -0
- data/spec/fixtures/ipn/recurring_payment_profile_created.json +31 -0
- data/spec/fixtures/ipn/recurring_payment_profile_created_with_initial_amount.json +33 -0
- data/spec/fixtures/ipn/recurring_payment_skipped.json +30 -0
- data/spec/fixtures/ipn/recurring_payment_with_initial_amount.json +44 -0
- data/spec/fixtures/notification/failure.yml +50 -0
- data/spec/fixtures/notification/success.yml +50 -0
- data/spec/paypal/adaptive_payments/api_spec.rb +20 -0
- data/spec/paypal/adaptive_payments/payment/base_spec.rb +28 -0
- data/spec/paypal/adaptive_payments/payment/create_spec.rb +63 -0
- data/spec/paypal/adaptive_payments/payment/details_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/payment/pay_spec.rb +97 -0
- data/spec/paypal/adaptive_payments/payment/refund_spec.rb +49 -0
- data/spec/paypal/adaptive_payments/payment/shipping_addresses_spec.rb +30 -0
- data/spec/paypal/adaptive_payments/payment_options/get_spec.rb +33 -0
- data/spec/paypal/adaptive_payments/payment_options/set_spec.rb +66 -0
- data/spec/paypal/adaptive_payments/preapproval/cancel_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/preapproval/create_spec.rb +39 -0
- data/spec/paypal/adaptive_payments/preapproval/details_spec.rb +34 -0
- data/spec/paypal/adaptive_payments/request_spec.rb +48 -0
- data/spec/paypal/api_spec.rb +78 -0
- data/spec/paypal/common/base_spec.rb +157 -0
- data/spec/paypal/common/error_data_spec.rb +0 -0
- data/spec/paypal/common/request_envelope_spec.rb +6 -0
- data/spec/paypal/common/response_spec.rb +0 -0
- data/spec/paypal/express_checkout/account/balance_spec.rb +25 -0
- data/spec/paypal/express_checkout/account/pal_details_spec.rb +20 -0
- data/spec/paypal/express_checkout/checkout/checkout_spec.rb +73 -0
- data/spec/paypal/express_checkout/checkout/details_spec.rb +70 -0
- data/spec/paypal/express_checkout/checkout/pay_spec.rb +68 -0
- data/spec/paypal/express_checkout/fields_spec.rb +138 -0
- data/spec/paypal/express_checkout/payment/refund_spec.rb +34 -0
- data/spec/paypal/express_checkout/payment/search_spec.rb +24 -0
- data/spec/paypal/express_checkout/payment/transaction_details_spec.rb +30 -0
- data/spec/paypal/express_checkout/payment_spec.rb +13 -0
- data/spec/paypal/express_checkout/recurring/create_profile_spec.rb +50 -0
- data/spec/paypal/express_checkout/recurring/manage_profile_spec.rb +62 -0
- data/spec/paypal/express_checkout/recurring/profile_spec.rb +44 -0
- data/spec/paypal/express_checkout/recurring/update_profile_spec.rb +50 -0
- data/spec/paypal/express_checkout/request_spec.rb +221 -0
- data/spec/paypal/express_checkout/response/account_spec.rb +33 -0
- data/spec/paypal/express_checkout/response/base_spec.rb +253 -0
- data/spec/paypal/invoice/cancel_spec.rb +38 -0
- data/spec/paypal/invoice/create_and_send_spec.rb +58 -0
- data/spec/paypal/invoice/create_spec.rb +58 -0
- data/spec/paypal/invoice/details_spec.rb +39 -0
- data/spec/paypal/invoice/mark_as_paid_spec.rb +75 -0
- data/spec/paypal/invoice/mark_as_refunded_spec.rb +47 -0
- data/spec/paypal/invoice/mark_as_unpaid_spec.rb +43 -0
- data/spec/paypal/invoice/search_spec.rb +70 -0
- data/spec/paypal/invoice/send_spec.rb +48 -0
- data/spec/paypal/invoice/update_spec.rb +72 -0
- data/spec/paypal/request_spec.rb +45 -0
- data/spec/spec_helper.rb +35 -0
- metadata +546 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
==============
|
2
|
+
Paypal Library
|
3
|
+
==============
|
4
|
+
|
5
|
+
Paypal Payment Express / Website Standard
|
6
|
+
Paypal Digital Goods
|
7
|
+
|
8
|
+
Paypal Mass Payment
|
9
|
+
|
10
|
+
Paypal Website Standard Recurring
|
11
|
+
|
12
|
+
Paypal Adaptive Payment
|
13
|
+
|
14
|
+
Paypay Invoice API
|
15
|
+
|
16
|
+
API Requirements:
|
17
|
+
|
18
|
+
1) Need to be non-blocking, use curb, DO NOT use net/http
|
19
|
+
https://rubygems.org/gems/curb
|
20
|
+
2) Support multi threading, avoid singleton
|
21
|
+
3) Formats:
|
22
|
+
Paypal::RecurringPayment
|
23
|
+
Paypal::ExpressPayment
|
24
|
+
Etc.
|
25
|
+
4) Include test framework with test account configuration
|
26
|
+
5) Documentation defined, with example
|
27
|
+
6) Extensible
|
28
|
+
7) Use paypal NVP
|
29
|
+
8) Refer to https://github.com/fnando/paypal-recurring
|
30
|
+
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'curb'
|
3
|
+
require 'multi_json'
|
4
|
+
require "paypal/api"
|
5
|
+
require "paypal/request"
|
6
|
+
require "paypal/common"
|
7
|
+
require "paypal/adaptive_payments"
|
8
|
+
require "paypal/invoice"
|
9
|
+
require "paypal/express_checkout"
|
10
|
+
require "paypal/permissions"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PayPal
|
2
|
+
module AdaptivePayments
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require "paypal/adaptive_payments/api"
|
7
|
+
require "paypal/adaptive_payments/response"
|
8
|
+
require "paypal/adaptive_payments/request"
|
9
|
+
require "paypal/adaptive_payments/base"
|
10
|
+
require "paypal/adaptive_payments/payment_info"
|
11
|
+
require "paypal/adaptive_payments/payment_info_list"
|
12
|
+
require "paypal/adaptive_payments/funding_type_info"
|
13
|
+
require "paypal/adaptive_payments/funding_type_list"
|
14
|
+
require "paypal/adaptive_payments/funding_constraint"
|
15
|
+
require "paypal/adaptive_payments/sender_identifier"
|
16
|
+
require "paypal/adaptive_payments/payment"
|
17
|
+
require "paypal/adaptive_payments/invoice_data"
|
18
|
+
require "paypal/adaptive_payments/invoice_item"
|
19
|
+
require "paypal/adaptive_payments/display_options"
|
20
|
+
require "paypal/adaptive_payments/sender_options"
|
21
|
+
require "paypal/adaptive_payments/receiver_options"
|
22
|
+
require "paypal/adaptive_payments/initiating_entity"
|
23
|
+
require "paypal/adaptive_payments/institution_customer"
|
24
|
+
require "paypal/adaptive_payments/payment_options"
|
25
|
+
require "paypal/adaptive_payments/receiver_list"
|
26
|
+
require "paypal/adaptive_payments/receiver"
|
27
|
+
require "paypal/adaptive_payments/phone"
|
28
|
+
require "paypal/adaptive_payments/preapproval"
|
29
|
+
require "paypal/adaptive_payments/client_details"
|
30
|
+
require "paypal/adaptive_payments/response/details"
|
31
|
+
require "paypal/adaptive_payments/response/pay_options"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module PayPal
|
2
|
+
module AdaptivePayments
|
3
|
+
class Api
|
4
|
+
|
5
|
+
API_ENDPOINTS = {
|
6
|
+
:sandbox => "https://svcs.sandbox.paypal.com/AdaptivePayments",
|
7
|
+
:production => "https://svcs.paypal.com/AdaptivePayments"
|
8
|
+
}
|
9
|
+
|
10
|
+
DATA_FORMATS = {
|
11
|
+
:nvp => 'NV',
|
12
|
+
:xml => 'XML',
|
13
|
+
:json => 'JSON'
|
14
|
+
}
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def username
|
18
|
+
PayPal::Api.instance.username
|
19
|
+
end
|
20
|
+
|
21
|
+
def password
|
22
|
+
PayPal::Api.instance.password
|
23
|
+
end
|
24
|
+
|
25
|
+
def signature
|
26
|
+
PayPal::Api.instance.signature
|
27
|
+
end
|
28
|
+
|
29
|
+
def app_id
|
30
|
+
PayPal::Api.instance.app_id
|
31
|
+
end
|
32
|
+
|
33
|
+
def environment
|
34
|
+
PayPal::Api.environment
|
35
|
+
end
|
36
|
+
|
37
|
+
def api_endpoint
|
38
|
+
API_ENDPOINTS[environment]
|
39
|
+
end
|
40
|
+
|
41
|
+
def request_data_format
|
42
|
+
DATA_FORMATS[:json]
|
43
|
+
end
|
44
|
+
|
45
|
+
def response_data_format
|
46
|
+
DATA_FORMATS[:json]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class ClientDetails
|
3
|
+
include PayPal::Common::Base
|
4
|
+
|
5
|
+
attr_accessor :application_id
|
6
|
+
attr_accessor :customer_id
|
7
|
+
attr_accessor :customer_type
|
8
|
+
attr_accessor :device_id
|
9
|
+
attr_accessor :geo_location
|
10
|
+
attr_accessor :ip_address
|
11
|
+
attr_accessor :model
|
12
|
+
attr_accessor :partner_name
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class InstitutionCustomer
|
3
|
+
include PayPal::Common::Base
|
4
|
+
|
5
|
+
attr_accessor :institution_id
|
6
|
+
attr_accessor :first_name
|
7
|
+
attr_accessor :last_name
|
8
|
+
attr_accessor :display_name
|
9
|
+
attr_accessor :institution_customer_id
|
10
|
+
attr_accessor :county_code
|
11
|
+
attr_accessor :email
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class InvoiceData
|
3
|
+
include PayPal::Common::Base
|
4
|
+
|
5
|
+
attr_accessor :item
|
6
|
+
attr_accessor :total_tax
|
7
|
+
attr_accessor :total_shipping
|
8
|
+
|
9
|
+
def set_item(value)
|
10
|
+
self.item = build_value(InvoiceItem, value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class Payment < PayPal::AdaptivePayments::Base
|
3
|
+
|
4
|
+
attr_accessor :action_type
|
5
|
+
attr_accessor :cancel_url
|
6
|
+
attr_accessor :client_details
|
7
|
+
attr_accessor :currency_code
|
8
|
+
attr_accessor :fees_payer
|
9
|
+
attr_accessor :funding_constraint
|
10
|
+
attr_accessor :ipn_notification_url
|
11
|
+
attr_accessor :memo
|
12
|
+
attr_accessor :pay_key
|
13
|
+
attr_accessor :pin
|
14
|
+
attr_accessor :preapproval_key
|
15
|
+
attr_accessor :receiver_list
|
16
|
+
attr_accessor :return_url
|
17
|
+
attr_accessor :reverse_all_parallel_payments_on_error
|
18
|
+
attr_accessor :sender
|
19
|
+
attr_accessor :sender_email
|
20
|
+
attr_accessor :tracking_id
|
21
|
+
attr_accessor :transaction_id
|
22
|
+
|
23
|
+
attr_accessor :payment_info_list
|
24
|
+
|
25
|
+
attr_accessor :response
|
26
|
+
|
27
|
+
def pay_key=(key)
|
28
|
+
@pay_key = key
|
29
|
+
@key = key
|
30
|
+
end
|
31
|
+
|
32
|
+
def receiver=(receiver)
|
33
|
+
self.receiver_list.only(receiver)
|
34
|
+
end
|
35
|
+
|
36
|
+
def receiver
|
37
|
+
self.receiver_list.first
|
38
|
+
end
|
39
|
+
|
40
|
+
def receiver_list
|
41
|
+
@receiver_list ||= ReceiverList.new
|
42
|
+
end
|
43
|
+
|
44
|
+
def create
|
45
|
+
self.action_type = 'CREATE'
|
46
|
+
run_pay
|
47
|
+
end
|
48
|
+
|
49
|
+
def pay
|
50
|
+
if self.pay_key
|
51
|
+
run_execute
|
52
|
+
else
|
53
|
+
self.action_type = 'PAY'
|
54
|
+
run_pay
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def pay_primary
|
59
|
+
self.action_type = 'PAY_PRIMARY'
|
60
|
+
run_pay
|
61
|
+
end
|
62
|
+
|
63
|
+
def details
|
64
|
+
Response.process(:payment_details, request.run(:payment_details, self.to_hash(:pay_key, :transaction_id, :tracking_id)))
|
65
|
+
end
|
66
|
+
|
67
|
+
def shipping_addresses
|
68
|
+
Response.process(:shipping_addresses, request.run(:shipping_addresses, self.to_hash(:key)))
|
69
|
+
end
|
70
|
+
|
71
|
+
def refund
|
72
|
+
Response.process(:refund, request.run(:refund, self.to_hash))
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_execute
|
76
|
+
Response.process(:execute_payment, request.run(:execute_payment, self.to_hash(:pay_key)))
|
77
|
+
end
|
78
|
+
|
79
|
+
def run_pay
|
80
|
+
self.response = Response.process(:pay, request.run(:pay, self.to_hash))
|
81
|
+
self.pay_key = self.response.pay_key
|
82
|
+
self.response
|
83
|
+
end
|
84
|
+
|
85
|
+
def payment_url
|
86
|
+
self.response && self.response.payment_url
|
87
|
+
end
|
88
|
+
|
89
|
+
def set_funding_constraint(value)
|
90
|
+
self.funding_constraint = build_value(FundingConstraint, value)
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_payment_info_list(value)
|
94
|
+
self.payment_info_list = build_value(PaymentInfoList, value)
|
95
|
+
end
|
96
|
+
|
97
|
+
def set_sender(value)
|
98
|
+
self.sender = build_value(SenderIdentifier, value)
|
99
|
+
end
|
100
|
+
|
101
|
+
def set_receiver(value)
|
102
|
+
self.receiver = build_value(Receiver, value)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class PaymentInfo
|
3
|
+
include PayPal::Common::Base
|
4
|
+
|
5
|
+
attr_accessor :transaction_id
|
6
|
+
attr_accessor :transaction_status
|
7
|
+
attr_accessor :receiver
|
8
|
+
attr_accessor :refunded_amount
|
9
|
+
attr_accessor :pending_refund
|
10
|
+
attr_accessor :sender_transaction_id
|
11
|
+
attr_accessor :sender_transaction_status
|
12
|
+
attr_accessor :pending_reason
|
13
|
+
|
14
|
+
def set_receiver(value)
|
15
|
+
self.receiver = build_value(Receiver, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module PayPal::AdaptivePayments
|
2
|
+
class PaymentOptions < PayPal::AdaptivePayments::Base
|
3
|
+
|
4
|
+
attr_accessor :pay_key
|
5
|
+
attr_accessor :display_options
|
6
|
+
attr_accessor :initiating_entity
|
7
|
+
attr_accessor :shipping_address_id
|
8
|
+
attr_accessor :sender_options
|
9
|
+
attr_accessor :receiver_options
|
10
|
+
|
11
|
+
def self.find(key)
|
12
|
+
self.new(:pay_key => key).get
|
13
|
+
end
|
14
|
+
|
15
|
+
def get
|
16
|
+
Response.process(:get_payment_options, request.run(:get_payment_options, self.to_hash))
|
17
|
+
end
|
18
|
+
|
19
|
+
def set
|
20
|
+
Response.process(:set_payment_options, request.run(:set_payment_options, self.to_hash))
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_display_options(value)
|
24
|
+
self.display_options = build_value(DisplayOptions, value)
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_initiating_entity(value)
|
28
|
+
self.initiating_entity = build_value(InitiatingEntity, value)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_sender_options(value)
|
32
|
+
self.sender_options = build_value(SenderOptions, value)
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_receiver_options(value)
|
36
|
+
self.receiver_options = build_value(ReceiverOptions, value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|