Created
November 1, 2016 12:44
-
-
Save kaiomagalhaes/d279fd8f9eb6fcf50e4b60c7dfa1684f to your computer and use it in GitHub Desktop.
paypal_plan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'paypal-sdk-rest' | |
require 'pry' | |
include PayPal::SDK::REST | |
include PayPal::SDK::Core::Logging | |
PayPal::SDK::REST.set_config( | |
:mode => "sandbox", # "sandbox" or "live" | |
:client_id => "mykey", | |
:client_secret => "mysecret") | |
PlanAttributes = { | |
"name" => "T-Shirt of the Month Club Plan", | |
"description" => "Template creation.", | |
"type" => "fixed", | |
"payment_definitions" => [ | |
{ | |
"name" => "Regular Payments", | |
"type" => "REGULAR", | |
"frequency" => "MONTH", | |
"frequency_interval" => "2", | |
"amount" => { | |
"value" => "100", | |
"currency" => "USD" | |
}, | |
"cycles" => "12", | |
"charge_models" => [ | |
{ | |
"type" => "SHIPPING", | |
"amount" => { | |
"value" => "10", | |
"currency" => "USD" | |
} | |
}, | |
{ | |
"type" => "TAX", | |
"amount" => { | |
"value" => "12", | |
"currency" => "USD" | |
} | |
} | |
] | |
} | |
], | |
"merchant_preferences" => { | |
"setup_fee" => { | |
"value" => "1", | |
"currency" => "USD" | |
}, | |
"return_url" => "http://www.return.com", | |
"cancel_url" => "http://www.cancel.com", | |
"auto_bill_amount" => "YES", | |
"initial_fail_amount_action" => "CONTINUE", | |
"max_fail_attempts" => "0" | |
} | |
} | |
AgreementAttributes = { | |
"name" => "T-Shirt of the Month Club Agreement", | |
"description" => "Agreement for T-Shirt of the Month Club Plan", | |
"start_date" => "2016-12-19T00:37:04Z", | |
"payer" => { | |
"payment_method" => "paypal" | |
}, | |
"shipping_address" => { | |
"line1" => "111 First Street", | |
"city" => "Saratoga", | |
"state" => "CA", | |
"postal_code" => "95070", | |
"country_code" => "US" | |
} | |
} | |
api = API.new | |
plan = Plan.new(PlanAttributes) | |
binding.pry | |
$agreement = Agreement.new(AgreementAttributes) | |
$agreement.plan = Plan.new( :id => "P-1K47639161110773GYDKTWIA" ) | |
$agreement.shipping_address = nil | |
binding.pry | |
$agreement.create |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment