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

Add logic for ApplePay #2

Merged
merged 4 commits into from
Jul 6, 2023
Merged

Add logic for ApplePay #2

merged 4 commits into from
Jul 6, 2023

Conversation

guillec
Copy link

@guillec guillec commented May 15, 2023

Partially for https://networkforgood.atlassian.net/browse/AIO-1422

In order for us to be able to use apple pay through spreedly, we had to fork the gem and update it just like we did for google pay. this is what we are doing on this PR.

making it apple pay good.

The main magic happens on lib/spreedly/environment.rb in which we check for the payment_type and build the XML as needed by spreedly.

This commit is not complete but it follows the same path as Google Pay.
We need to see what token Apple returns in order to fill up the stub
object we created for specs.
@guillec guillec changed the title Add logic for ApplePay WIP Add logic for ApplePay May 15, 2023
@guillec guillec requested a review from kcpavan May 15, 2023 18:12
@guillec
Copy link
Author

guillec commented May 15, 2023

@kcpavan I put together this draft. once we get the token from Apple we need to update the stub.

<payment_data><![CDATA[#{payment_method_token}]]></payment_data>
#{'<test_card_number>4111111111111111</test_card_number>' if options[:test_mode]}
</apple_pay>
XML
Copy link
Author

Choose a reason for hiding this comment

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

We can probably do something fancier here in which we use the value of the options[:payment_method] as the value for <apple_pay> or <google_pay>

Example:

doc << <<~XML
  <#{options[:paymet_method]}
    ....
  </#{options[:paymet_method]}

guillec added 3 commits June 7, 2023 10:04
I had placed the apple_pay payment_method file in the incorrect
location. And I was missing a apple pay token sample.

This commit fixes both issues.
@guillec guillec changed the title WIP Add logic for ApplePay Add logic for ApplePay Jun 7, 2023
@guillec guillec requested review from joseluistorres and hoenth June 7, 2023 18:18
Comment on lines +2 to +6

class ApplePay < PaymentMethod

end

Choose a reason for hiding this comment

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

do we need the extra space?

Copy link

@joseluistorres joseluistorres left a comment

Choose a reason for hiding this comment

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

LGTM! I feel we need a plan (epic in JIRA) to make sure this gem keeps up with the original or pretty much assume that we have a risk that Spreedly decides to break their API or something and we deal with it in the future 🤷

Copy link

@joseluistorres joseluistorres left a comment

Choose a reason for hiding this comment

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

LGTM! I feel we need a plan (epic in JIRA) to make sure this gem keeps up with the original or pretty much assume that we have a risk that Spreedly decides to break their API or something and we deal with it in the future 🤷

@hoenth
Copy link

hoenth commented Jun 8, 2023

@joseluistorres I agree. We should at least issue a PR against the spreedly/spreedly-gem

@guillec
Copy link
Author

guillec commented Jun 8, 2023

@joseluistorres @hoenth yeah the plan has always been to try to get this accepted on the main gem. although I accidentally opened two PR already on the main gem... so they know its coming :)

@guillec guillec requested a review from darwinwhaley June 21, 2023 13:14
Copy link

@kcpavan kcpavan left a comment

Choose a reason for hiding this comment

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

Looks good to me

@@ -28,6 +28,8 @@ def self.new_from(xml_doc)
return ThirdPartyToken.new(xml_doc)
when 'google_pay'
return GooglePay.new(xml_doc)
when 'apple_pay'
return ApplePay.new(xml_doc)

Choose a reason for hiding this comment

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

Not an issue, just a Ruby newbie question about performance. When ordering a "case" statement, is any thought given to ordering the "when"s so that the most likely hits are at the top, and the least likely are at the bottom?

Copy link

Choose a reason for hiding this comment

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

Probably up to the individual engineer, and whether there is a real world difference between the options. So yes, in some cases, but there is nothing dogmatic that we follow.

Copy link
Author

Choose a reason for hiding this comment

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

I've never really thought about it, I guess is you have a very large case statement it could have an effect but in general i would say the gains would be minimal.

Choose a reason for hiding this comment

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

Yeah I agree, in this case the gain would be marginal since each option is a simple string.

@joseluistorres
Copy link

@joseluistorres @hoenth yeah the plan has always been to try to get this accepted on the main gem. although I accidentally opened two PR already on the main gem... so they know its coming :)

Heads up, I posted this on their gem a few weeks ago, I'm merging this for now 🙏
spreedly#121

@joseluistorres joseluistorres merged commit c086fb8 into master Jul 6, 2023
@joseluistorres joseluistorres deleted the accept_apple_pay branch July 6, 2023 20:29
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.

5 participants