Creating transactions
Using card nonces
Include the Google Pay card nonce in the Transaction: Sale call on your server:
Collect device data from the client and include the deviceDataFromTheClient
in the transaction.
var request = new TransactionRequest
{
Amount = 10.00M,
PaymentMethodNonce = nonceFromTheClient,
DeviceData = deviceDataFromTheClient,
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
},
BillingAddress = new AddressRequest
{
PostalCode = postalCodeFromTheClient
},
};
Result<Transaction> result = gateway.Transaction.Sale(request);
Using PayPal nonces
PayPal nonces returned from the client will be a PayPalAccount
type rather than an AndroidPayCard
. To create a transaction with a PayPal nonce:
Collect device data from the client and include the deviceDataFromTheClient
in the transaction.
TransactionRequest request = new TransactionRequest
{
Amount = 1000.0M,
PaymentMethodNonce = Request.Form["payment_method_nonce"],
DeviceData = Request.Form["device_data"],
OrderId = "Mapped to PayPal Invoice Number",
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true,
PayPal = new TransactionOptionsPayPalRequest
{
CustomField = "PayPal custom field",
Description = "Description for PayPal email receipt"
},
}
};
Result<Transaction> result = gateway.Transaction.Sale(request);
if (result.IsSuccess())
{
System.Console.WriteLine("Transaction ID: " + result.Target.Id);
}
else
{
System.Console.WriteLine(result.Message);
}
Because creating a transaction with a PayPalAccount
nonce from Google Pay is effectively the same as creating a transaction from your PayPal integration, they have the same settlement rules and options that typical PayPal transactions have.
When making a transaction with PayPalAccount
nonce through Google Pay, the resulting transaction will have FacilitatorDetails.OauthApplicationName
set to Google
.
Vaulting Google Pay
Google Pay cards can only be saved to your Vault for specific use cases; see the support article for details.
Vaulting of PayPal accounts from Google Pay is currently not supported. This means the Options.StoreInVault and Options.StoreInVaultOnSuccess options are not supported when creating a transaction.
If your use case is supported, you can store a customer's Google Pay card in your Vault in a few different ways:
- In a separate Payment Method: Create request
- In a separate Customer: Create or Customer: Update request
- In your Transaction: Sale request by using Options.StoreInVault or Options.StoreInVaultOnSuccess