Authorize Google Pay payments.
Notes:
For more details see Google Pay.
Performs the authorization via the Payment Service to complete the payment.
POST /mobile/googlepay/merchants/{merchant_key}/payments/{order_key}/authorize
Identifiers
Name | Type | Description |
---|---|---|
merchant_key | MerchantKey | The key of the merchant. |
order_key | OrderKey | The key of the order. |
Parameters
Not applicable.
Request
The paymentData.paymentMethodData
received from the Google Payments client needs to be send as-is to the Payment System.
Modifications are not allowed.
Response
Not applicable.
HTTP Status
Status | Meaning |
---|---|
200 (OK) | The payment is successfully authorized. |
400 (Bad Request) | The request was not valid. |
500 (Internal Server Error) | Something went wrong in processing the request. |
Initialize Google Pay example
Command Line:
> curl \
-X POST \
--header 'Content-Type: application/json' \
https://testsecure.docdatapayments.com/mobile/googlepay/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/payments/94D261BBF80E4AC7212B127D3BD2E279/authorize \
-d '{
"..." : "...",
}'
< Http 200 Ok
JavaScript:
function authorizeGooglePayPayment(merchantKey, orderKey, serverUrl, environment, request) {
const paymentsClient = getGooglePaymentsClient();
paymentsClient.loadPaymentData(JSON.parse(request))
.then(function(paymentData) {
window.showGooglePaySpinner();
// handle the response
processPayment(merchantKey, orderKey, serverUrl, JSON.stringify(paymentData.paymentMethodData));
})
.catch(function(e) {
console.error(e);
});
}
function getGooglePaymentsClient(environment) {
if ( paymentsClient === null ) {
paymentsClient = new google.payments.api.PaymentsClient({environment: environment});
}
return paymentsClient;
}
function processPayment(merchantKey, orderKey, serverUrl, paymentMethodData) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4) {
console.debug("Got response from Payment Server, polling order status...");
window.pollOrderStatus();
}
};
var authorizationUrl = serverUrl + "/mobile/googlepay/merchants/" + merchantKey + "/payments/" + orderKey + "/authorize";
xhttp.open("POST", authorizationUrl, true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(paymentMethodData);
}