payment-data-cryptography-dotnet
payment-data-cryptography-dotnet copied to clipboard
can this library be used to implement pass callbacks
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) {
// …
}
}
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?
Is there a solution to this?
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 ~~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!