Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def process
- !!if valid_card
- gateway :authorize, credit_card do |auth|
- gateway :capture, auth do |auth|
- update_columns(authorization_code: auth, success: true)
- end
- end
- end
- end
- def gateway(method, subject)
- response = GATEWAY.public_send(method, amount * 100, subject)
- if response.success?
- yield response.authorization
- else
- errors.add(:base, "The credit card you provided was declined. Please double check your information and try again.") and return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement