Paypal Payflowpro example
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
@secure_token_id = UUID.generate.gsub('-', '').slice(0, 25) | |
current_user.update_attribute(:paypal_token_id, @secure_token_id) | |
paypal_params = {'PARTNER' => 'PayPal', 'VENDOR' => PAYPAL_USER, 'USER' => PAYPAL_USER, \ | |
'PWD' => PAYPAL_MANAGER_PASSWORD, 'TRXTYPE' => 'S', 'AMT' => cost, 'CREATESECURETOKEN' => 'Y', \ | |
'SECURETOKENID' => @secure_token_id | |
}.to_param | |
paypal_params += "&RETURNURL=#{paypal_success_url}&ERRORURL=#{paypal_error_url}&SILENTPOSTURL=#{paypal_silent_post_url}&CANCELURL=#{subscribe_url}" | |
Rails.logger.warn 'PAYPAL TOKEN REQUEST PARAMS' | |
Rails.logger.warn paypal_params | |
# Pilot URL is for sandbox testing | |
# Hit api with secure_token_id to get secure token to allow transaction | |
if Rails.env.development? | |
paypal_response = %x[ curl https://pilot-payflowpro.paypal.com -kd "#{ paypal_params }" ] | |
else | |
paypal_response = %x[ curl https://payflowpro.paypal.com -kd "#{ paypal_params }" ] | |
end | |
Rails.logger.warn 'PAYPAL RESPONSE' | |
Rails.logger.warn paypal_response | |
parsed_response = Rack::Utils.parse_query(paypal_response) | |
Rails.logger.warn 'PARSED RESPONSE' | |
Rails.logger.warn parsed_response | |
if parsed_response['RESULT'] == "0" | |
# Pull out token to use in iframe url | |
@secure_token = parsed_response['SECURETOKEN'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment