payment-data-cryptography-dotnet icon indicating copy to clipboard operation
payment-data-cryptography-dotnet copied to clipboard

can this library be used to implement pass callbacks

Open dolphinsd opened this issue 4 years ago • 4 comments

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) {
   // …
}

}

dolphinsd avatar Mar 11 '20 01:03 dolphinsd

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?

andrey-davydenko avatar Aug 10 '20 15:08 andrey-davydenko

Is there a solution to this?

shazadmaved avatar Feb 05 '21 04:02 shazadmaved

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.

shazadmaved avatar Feb 12 '21 13:02 shazadmaved

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

rahulpnath avatar Apr 22 '22 00:04 rahulpnath