On This Page
Formatting Encrypted Payment Data
This section shows you how to format encrypted payment data using these procedures:
Configuring Google Pay
You must provide your
Cybersource
merchant ID to Google in order to
ensure proper encryption of the Google Pay payload and authenticity of the request.For a Google Pay tutorial, see Google Pay for Payments.
Set the gateway and gateway merchant ID to the appropriate indicators. The following code
examples show how to configure the
PaymentMethodTokenizationParameters
object using Cybersource
as the gateway.Example: Java Code
.setPaymentMethodTokenizationType(WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY) .addParameter("gateway", "") .addParameter("gatewayMerchantId", "[yourCybersourceMID]")
Example: JavaScript Code
tokenizationType: 'PAYMENT_GATEWAY', parameters: { gateway: 'cybersource', gatewayMerchantId: '[yourCybersourceMID]'
Example: Java Code
.setPaymentMethodTokenizationType(WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY) .addParameter("gateway", "cybersource") .addParameter("gatewayMerchantId", "[yourCybersourceMID]")
Example: JavaScript Code
tokenizationType: 'PAYMENT_GATEWAY', parameters: { gateway: 'cybersource', gatewayMerchantId: '[yourCybersourceMID]'
Formatting Payment Blobs
IMPORTANT
This section is only applicable if you are using the
Cybersource
decryption method.To prepare the Google Pay payload for submission to
Cybersource
, you must
extract the token data element from the Google Pay payload and encode the token data
element using Base64.These samples can be used to Base64-encode payment responses:
JavaScript
let token = paymentData.paymentMethodData.tokenizationData.token; console.log(token); var enc=window.btoa(token);
Android with Java
This sample uses the Android Studio Base64 utility.
public static <outputString> encodeToString (byte[] <inputToken>, int DEFAULT)
Apple iPhone with Swift 3
This sample requires the Foundation utility.
extension String { func base64Encoded() -> <outputString> if let data = self.dat(using:.utf8) { return data.base64EncodedString() } return nil }
Sample Code
The following samples can be used to Base64-encode payment responses:
JavaScript
let token = paymentData.paymentMethodData.tokenizationDta.token; console.log(token); var enc=window.btoa(token);
Android with Java
This sample uses the Android Studio Base64 utility.
public static <outputString> encodeToString (byte[] <inputToken>, int DEFAULT)
Apple iPhone with Swift 3
This sample requires the Foundation utility.
extension String { func base64Encoded() -> <outputString> if let data = self.dat(using:.utf8) { return data.base64EncodedString() } return nil }
Example: Unencrypted Google Pay Response
{"signature":"MEUCIQDhTxhHqwY8pXB9hpYxaSK5jFgsqpG2E1rX77QXssK8tAIgUBvYYAI/ bnBS8T/Tfxnm2AF981Mv5y0pHyGexM5dMJk\u003d","protocolVersion":"ECv1"," signedMessage":"{\"encryptedMessage\":\" odyUGGA7B+blletYcJbS43AQUFQJpWEFCN4UuUExQ5LX0\/ XcLwKElXcB95nMnmPO9lM2KGp13FYsL768ccCzAjBGLYF+ fugcJTcvkrUhcNSyXr7hwf12BEsrweqJM6I7Vs5lfrPAukRJeLDQG4FxmTLW49QyP8vIZC+ tz2c+Z3zozzI5oB9jE8fA2dolFa13Cu6gXqdKH\/ IHRh7UniLUuTy+0G5FQV2pwST2uBSNNkZhb8WYJDHbxBjz0UebVP+ ObmT5cc8AKU5dgHRdfr4GKpEZ4EBzB90 BPxLqYHpopriJ6lbFgFVsQQ6\/ 8HBqQ7ImIMH5y7G8p8qAFkWnB78ZcL0Fh5BjXojkxGoFp2gjAsrhhttHAFbe3WQBuPkwJu09\/ 6\/MyJpCSrpMHFouF\/dj0SYjQ+xI097lCHZec7jQrAhISLWZ9DZkuMvGKPWpu0CKn2XqTXQ=\ ",\"ephemeralPublicKey\":\ "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnn4yjy0N6xlXO8\/8j7\/ 4jvmLJCYAqgXLwP1FhjuTgIM9oCtPijZfI9so2QEOs2ZnVp3D0dl3JYIDVe+396KkAQ==\ ",\"tag\":\"DRp cc+YQ33RNgsTcxztnJbMJnirbU5DW3dStjfhFiwc=\"}"}
Examples of Google Pay Responses
Decrypted Google Pay Response
{"signature":"MEUCIQDhTxhHqwY8pXB9hpYxaSK5jFgsqpG2E1rX77QXssK8tAIgUBvYYAI/ bnBS8T/Tfxnm2AF981Mv5y0pHyGexM5dMJk\u003d","protocolVersion":"ECv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