Class: ActiveMerchant::Billing::PaypalStandardGateway
- Defined in:
- lib/active_merchant/billing/gateways/paypal_standard.rb
Constant Summary collapse
- ENDPOINTS =
{ generate_token: '/v1/oauth2/token', create_order: '/v2/checkout/orders', capture_order: '/v2/checkout/orders/%{id}/capture', refund: '/v2/payments/captures/%{id}/refund' }
- SOFT_DECLINE_CODES =
%w[INVALID_REQUEST AUTHENTICATION_FAILURE UNPROCESSABLE_ENTITY RATE_LIMIT_REACHED].freeze
- SUCCESS_CODES =
%w[COMPLETED].freeze
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #capture(authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PaypalStandardGateway
constructor
A new instance of PaypalStandardGateway.
- #purchase(amount, payment_method, options = {}) ⇒ Object
- #refund(amount, authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ PaypalStandardGateway
Returns a new instance of PaypalStandardGateway.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_merchant/billing/gateways/paypal_standard.rb', line 22 def initialize( = {}) requires!(, :client_id, :client_secret) @client_id = [:client_id] @client_secret = [:client_secret] @response_http_code = nil super @access_token = setup_access_token @request_id = SecureRandom.uuid end |
Instance Method Details
#capture(authorization, options = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/active_merchant/billing/gateways/paypal_standard.rb', line 45 def capture(, = {}) post = {} commit(:capture_order, post, ) end |
#purchase(amount, payment_method, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/active_merchant/billing/gateways/paypal_standard.rb', line 33 def purchase(amount, payment_method, = {}) post ||= {} amount = to_currency(amount) add_payment_intent(post) add_purchase_units(post, amount, ) add_payment_source(post, payment_method, ) commit(:create_order, post) end |
#refund(amount, authorization, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_merchant/billing/gateways/paypal_standard.rb', line 51 def refund(amount, , = {}) post = {} amount = to_currency(amount) add_refund_amount(post, amount, ) add_refund_reason(post, ) commit(:refund, post, ) end |