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

Extend README with usage and complete example #13

Merged
merged 5 commits into from
Jun 4, 2018
Merged

Conversation

ct-clearhaus
Copy link
Member

Please feel free to push improvements 🙂

README.md Outdated

# Validate the decrypted data; raises an Pedicel::Validator::Error if the
# format is invalid.
Pedicel::Validator.validate_token_data(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this step becomes superfluous due to #14 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually not, because this is a validation of the decrypted token data whereas #14 introduces automatic validation of the inputted (unencrypted) token.

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I'd use the term Payment Data somewhere in the comment, it's what Apple calls the data. As above, you could also link to what tests are being performed.

Copy link
Member Author

@ct-clearhaus ct-clearhaus left a comment

Choose a reason for hiding this comment

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

👍 to your corrections @mt-clearhaus.

@ct-clearhaus ct-clearhaus requested review from mt-clearhaus and kse-clearhaus and removed request for kse-clearhaus June 1, 2018 12:30
kse-clearhaus
kse-clearhaus previously approved these changes Jun 4, 2018
README.md Outdated
# Instantiate.
# Validates the format of the Apple Pay payment token; raises an
# Pedicel::Validator::Error if the format is invalid.
pedicel = Pedicel::EC.new(apple_pay_payment_token_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor comment: We could mention that the rules for the check exist at https://developer.apple.com/library/content/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html.

We should maybe mention that it does not support using RSA.

Copy link
Member Author

Choose a reason for hiding this comment

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

What section do you refer to?

If the bullets below step 6 of the "to decrypt" steps: we cannot check that currencyCode and transactionAmount is correct (because that's not the job of this gem).

If the table below "Payment Data Keys": we do not ensure that it is indeed an ISO 4217 numeric code.

If we should refer to anything, then I think it should be the code. An addition could be a checklist of things the user of this gem should check on their own.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right about step 6 :)

I leave it at your discretion, but I would refer to step 1, which is essentially what the checks boil down to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, I misunderstood what you meant (I thought about the Validator stuff, my bad).

"Validates the format" is not exactly right. It's more like "Validates the content". I'll adjust.

Copy link
Member Author

Choose a reason for hiding this comment

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

The errors have "Format" in their name:

class TokenFormatError < Error; end
class TokenDataFormatError < Error; end

Should we adjust? To TokenError and TokenDataError? WDYT @kse-clearhaus @mt-clearhaus?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Validator stuff is more about format, so I guess it's acceptable. Otherwise, perhaps TokenSchemaError and TokenDataSchemaError?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. It is about format, but not just, i.e. signature checking.
Maybe TokenContentError and TokenDataContentError.

But either will do.

README.md Outdated

# Validate the decrypted data; raises an Pedicel::Validator::Error if the
# format is invalid.
Pedicel::Validator.validate_token_data(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I'd use the term Payment Data somewhere in the comment, it's what Apple calls the data. As above, you could also link to what tests are being performed.

README.md Outdated
sk = pedicel.symmetric_key(private_key: pk, merchant_id: mid)
```

## Complete test using `pedicel-pay`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should state briefly why people would need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

People could use it for things we haven't thought about. It's basically just an example that one can carry out. I'll rename it to include the word "example".

README.md Outdated
# Decrypt using the merchant private key and merchant certificate.
# The merchant private key `pk` and merchant certificate `c` are generated
# during the Apple Pay merchant sign-up.
data = pedicel.decrypt(private_key: pk, certificate: c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Apple call it Apple Pay Merchant Identity Certificate. There also the Apple Pay Payment Processing Certificate, I'm not sure what this is to be used for, yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

https://developer.apple.com/documentation/apple_pay_on_the_web/configuring_your_environment

Payment Processing Certificate. A certificate associated with your merchant ID, used to secure transaction data. Apple Pay servers use the certificate’s public key to encrypt payment data. You, or your payment service provider, use the private key to decrypt data to process payments. See Create a payment processing certificate for the setup steps.

Merchant Identity Certificate. A Transport Layer Security (TLS) certificate associated with your merchant ID, used to authenticate your sessions with the Apple Pay servers. The merchant identity certificate is only required for Apple Pay on the web; it isn't needed for apps. See Create a merchant identity certificate for the setup steps.

So I guess the Merchant Identity Certificate is a TLS client cert that can be handled by a merchant (which is not in scope for PCI DSS) and the Payment Processing Certificate is the cert to which they payment data is encrypted to which should thus be handled by a PCI DSS approved party (usually the PSP/gateway).

mt-clearhaus
mt-clearhaus previously approved these changes Jun 4, 2018
Copy link
Contributor

@mt-clearhaus mt-clearhaus left a comment

Choose a reason for hiding this comment

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

👍

However, I agree with the suggestions put forth by @kse-clearhaus .

README.md Outdated
## Complete test using `pedicel-pay`
## Example

Creating keys, certificates, CSRs, do signing, etc. is a tad cumbersome, so we
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps s/ do//.

Copy link
Contributor

@kse-clearhaus kse-clearhaus 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!

@ct-clearhaus ct-clearhaus merged commit a2ccee0 into master Jun 4, 2018
@ct-clearhaus ct-clearhaus deleted the extend-readme branch June 4, 2018 12:32
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.

3 participants