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]'
Formatting Payment Blobs
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 }