Class: PayPal::ExpressCheckout::Checkout

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/express_checkout/checkout.rb

Constant Summary

Constants included from Fields

Fields::ASSOCIATIONS, Fields::ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Base

#initialize, #request, #run

Methods included from Fields

#field_map, #group_collect, #group_fields, #has_fields?, #has_many?, included, #inverted_field_map

Constructor Details

This class inherits a constructor from PayPal::ExpressCheckout::Base

Instance Method Details

#address_verifyObject

Verify an address.

ppr = PayPal::ExpressCheckout::Checkout.new({
  :email  => "[email protected]",
  :street => "ABCEDFGH",
  :zip    => "1234"
})
response = ppr.refund


60
61
62
63
64
65
66
67
68
# File 'lib/paypal/express_checkout/checkout.rb', line 60

def address_verify
  params = collect(
    :email,
    :street,
    :zip
  )

  run(:address_verify, params)
end

#authorizeObject

Do authorization



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/paypal/express_checkout/checkout.rb', line 86

def authorize
  params = collect(
    :transaction_id,
    :amount,
    :transaction_entity,
    :currency,
    :msg_sub_id
  )

  run(:authorize, params)
end

#captureObject

Do capture



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/paypal/express_checkout/checkout.rb', line 114

def capture
  params = collect(
    :authorization_id,
    :amount,
    :currency,
    :complete_type,
    :invoice_no,
    :note,
    :soft_descriptor,
    :msg_sub_id,
    :store_id,
    :terminal_id
  )

  run(:capture, params)
end

#checkoutObject

Request a checkout token.

ppr = PayPal::ExpressCheckout::Checkout.new({
  :return_url         => "http://example.com/checkout/thank_you",
  :cancel_url         => "http://example.com/checkout/canceled",
  :ipn_url            => "http://example.com/paypal/ipn",
  :description        => "Awesome - Monthly Subscription",
  :amount             => "9.00",
  :currency           => "USD"
})

response = ppr.request_token
response.checkout_url


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/paypal/express_checkout/checkout.rb', line 22

def checkout
  params = group_collect(
    :checkout,
    :giro,
    :gift,
    :survey,
    :buyer,
    :tax,
    :landing_page, 
    :solution_type, 
    :channel_type,
    :payments,
    :shipping_options,
    :billings
  )

  run(:checkout, params)
end

#detailsObject

Return checkout details.

ppr = PayPal::ExpressCheckout::Checkout.new({
  :token => "EC-6LX60229XS426623E"
})
response = ppr.details


48
49
50
# File 'lib/paypal/express_checkout/checkout.rb', line 48

def details
  run(:details, :token => token)
end

#payObject

Execute payment. DoExpressCheckoutPayment



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/paypal/express_checkout/checkout.rb', line 71

def pay
  params = group_collect(
    :token,
    :payer_id,
    :return_fmf_details,
    :payments,
    :survey,
    :shipping_option
  )

  run(:pay, params)
end

#reauthorizeObject

Do authorization



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/paypal/express_checkout/checkout.rb', line 100

def reauthorize
  params = collect(
    :transaction_id,
    :amount,
    :transaction_entity,
    :currency,
    :msg_sub_id
  )

  run(:reauthorize, params)
end

#voidObject

Do void



133
134
135
136
137
138
139
140
141
# File 'lib/paypal/express_checkout/checkout.rb', line 133

def void
  params = collect(
    :authorization_id,
    :note,
    :msg_sub_id
  )

  run(:void, params)
end