Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProPay: Add gateway #2405

Closed
wants to merge 1 commit into from
Closed

Conversation

davidsantoso
Copy link
Member

@davidsantoso davidsantoso commented Apr 26, 2017

Adding the ProPay gateway. Just to note- still waiting on the production URL. I'll update the PR once it's given before merging in.

Remote Test Run

➜ ruby -Itest test/remote/gateways/remote_pro_pay_test.rb
Loaded suite test/remote/gateways/remote_pro_pay_test
Started
...................

Finished in 58.230136 seconds.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
19 tests, 49 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.33 tests/s, 0.84 assertions/s

Unit Test Run

➜ ruby -Itest test/unit/gateways/pro_pay_test.rb
Loaded suite test/unit/gateways/pro_pay_test
Started
................

Finished in 0.069866 seconds.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
229.01 tests/s, 973.29 assertions/s

self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express, :discover]

self.homepage_url = 'http://www.example.net/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep 😞

def refund(money, authorization, options={})
request = build_xml_request do |xml|
xml.transNum authorization
xml.amount money if money
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this (and the one in capture) be amount(money)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should! Good catch.

def capture(money, authorization, options={})
request = build_xml_request do |xml|
xml.amount money if money
xml.transNum authorization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about having both these direct additions to the xml in the action methods, and the one-line add_account and add_recurring methods extracted. Not a big deal though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. Sometimes I think it's ok to have the method just add the single value instead of always using any extracted methods. But, the more I think about it, it's probably better for me to keep using to extracted methods.


def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(100, credit_card, options) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't accept 0-value authorizes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I didn't try it actually. I've actually always gone off of the 100 that comes with the generator. I'll give it a shot and see what happens.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried 0 auth during verify and got an Invalid amount error. 😿

end

def add_recurring(xml, options)
xml.recurringPayment options[:recurring_payment]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any best practice for options passed to a gateway that are boolean being true/false vs the value of what's actually passed to the gateway? Or are there more options than Y/N?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've personally always thought it's better to pass the same value as what's in the gateway docs. Seems more explicit to me instead of relying on the underly adapter to do the right thing depending on true/false. That being said, I don't think there's actually a convention around this yet...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that does make sense; I'll try to remember to follow that in the future.

@davidsantoso
Copy link
Member Author

Alrighty, updates made. Thanks for the second set of eyes @curiousepic. Just waiting on the production URL from ProPay now...

@davidsantoso
Copy link
Member Author

Live URL added. Just waiting on a 👍!

@curiousepic
Copy link
Contributor

@shasum Want to give a once-over and 👍 ?

Copy link
Contributor

@curiousepic curiousepic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@shasum shasum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good 👍

module Billing #:nodoc:
class ProPayGateway < Gateway
self.test_url = 'https://xmltest.propay.com/API/PropayAPI.aspx'
self.live_url = 'https://example.com/live'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this one, the live_url? :)

request = build_xml_request do |xml|
xml.transNum authorization
xml.amount money if money
xml.currencyCode if options[:currency]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's needed. Noticed capture does not have currency code unlike refund.

end

def add_account(xml, options)
xml.accountNum options[:account_num]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is account_num likely to change per transaction. Just want to make sure it's better as an option vs a credential.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shasum great question! Yes it is. ProPay is a payment gateway for platforms so for each transaction you need to specify the merchant (on your platform) that you want to actually receive the funds. Similar to WePay.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

@davidsantoso
Copy link
Member Author

Thanks @shasum and @curiousepic!

asanger pushed a commit to asanger/active_merchant that referenced this pull request Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants