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

can this library be used to implement pass callbacks #9

Open
dolphinsd opened this issue Mar 11, 2020 · 4 comments
Open

can this library be used to implement pass callbacks #9

dolphinsd opened this issue Mar 11, 2020 · 4 comments

Comments

@dolphinsd
Copy link

dolphinsd commented Mar 11, 2020

We are looking for c# solution to implement pass callbacks like this below taken from here:
https://developers.google.com/pay/passes/guides/overview/how-to/use-callbacks

Can we use this library, if so, can you provide with an example?

private static final String PUBLIC_KEY_URL = "https://pay.google.com/gp/m/issuer/keys". // Public key URL provided by Google.
private static final String SENDER_ID = "GooglePayPasses". // Constant.

private static final String RECIPIENT_ID = "ISSUER_ID". // Replace ISSUER_ID with your issuer id.

private static final String PROTOCOL = "ECv2SigningOnly".
Private static final GooglePaymentsPublicKeysManager keysManager = new
GooglePaymentsPublicKeysManager.Builder()
.setKeysUrl(PUBLIC_KEY_URL)
.build();

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
// Extract signed message with signature from POST request body.
String signedMessage = CharStreams.toString(request.getReader());
recipient =
new PaymentMethodTokenRecipient.Builder()
.protocolVersion(PROTOCOL)
.fetchSenderVerifyingKeysWith(keysManager)
.senderId(SENDER_ID)
.recipientId(RECIPIENT_ID)
.build();

  String serializedJsonMessage = recipient.unseal(signedMessage);
  // Use serializedJsonMessage to extract the details.
} catch (Exception e) {
   // …
}

}

@andrey-davydenko
Copy link

We are looking for c# solution to implement pass callbacks like this below taken from here:
https://developers.google.com/pay/passes/guides/overview/how-to/use-callbacks

Can we use this library, if so, can you provide with an example?

private static final String PUBLIC_KEY_URL = "https://pay.google.com/gp/m/issuer/keys". // Public key URL provided by Google.
private static final String SENDER_ID = "GooglePayPasses". // Constant.

private static final String RECIPIENT_ID = "ISSUER_ID". // Replace ISSUER_ID with your issuer id.

private static final String PROTOCOL = "ECv2SigningOnly".
Private static final GooglePaymentsPublicKeysManager keysManager = new
GooglePaymentsPublicKeysManager.Builder()
.setKeysUrl(PUBLIC_KEY_URL)
.build();

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
// Extract signed message with signature from POST request body.
String signedMessage = CharStreams.toString(request.getReader());
recipient =
new PaymentMethodTokenRecipient.Builder()
.protocolVersion(PROTOCOL)
.fetchSenderVerifyingKeysWith(keysManager)
.senderId(SENDER_ID)
.recipientId(RECIPIENT_ID)
.build();

  String serializedJsonMessage = recipient.unseal(signedMessage);
  // Use serializedJsonMessage to extract the details.
} catch (Exception e) {
   // …
}

}

Did you manage to find the solution?

@shazadmaved
Copy link

Is there a solution to this?

@shazadmaved
Copy link

shazadmaved commented Feb 12, 2021

I have changed the implementation and included ECv2SigningOnly by changing the sender id, recipient id and public keys url. I have commented the decrypting part which not necessary for ECv2SigningOnly, and it worked.

@rahulpnath
Copy link
Contributor

rahulpnath commented Apr 22, 2022

@shazadmaved By any chance do you have a sample uploaded anywhere? Looking to do exactly the same
Got it working after playing around with it a bit - I will raise a PR into this repo soon!

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

No branches or pull requests

4 participants