11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/generators/paypal/scaffold/scaffold_generator.rb', line 11
def generate_scaffold
copy_file "app/models/paypal_api.rb", "app/models/paypal_api.rb"
if File.exist?( 'config/initializers/local_setting.rb' )
content = "\n# PayPal\n"
content += "ENV['PAYPAL_USER_NAME'] = \"YOUR API Username\"\n"
content += "ENV['PAYPAL_PASSWORD'] = \"YOUR API Password\"\n"
content += "ENV['PAYPAL_SIGNATURE'] = \"YOUR Signature\"\n"
append_file( "config/initializers/local_setting.rb", content.force_encoding('ASCII-8BIT') )
else
copy_file( "config/initializers/local_setting.rb", "config/initializers/local_setting.rb" )
end
if File.exist?( 'config/initializers/constants.rb' )
content = "\n# PayPal\n"
content += "if Rails.env.production?\n"
content += " PAYPAL_SANDBOX = \"OFF\"\n"
content += "else\n"
content += " PAYPAL_SANDBOX = \"ON\"\n"
content += "end\n"
content += "\n# PayPal Recurring\n"
content += "PAYPAL_RECURRING_PERIOD = :Month # 周期 ie.) :Month, :Week, :Day\n"
content += "PAYPAL_RECURRING_FREQUENCY = 1 # 回数\n"
content += "PAYPAL_RECURRING_AMOUNT = 150 # 金額\n"
append_file( "config/initializers/constants.rb", content.force_encoding('ASCII-8BIT') )
else
copy_file( "config/initializers/constants.rb", "config/initializers/constants.rb" )
end
end
|