Declare the version of the Google Pay API that your site uses. The major and minor versions are required in the fields of each passed object, and are included in the response.
The following code sample shows declared API versions:
Replace example and exampleGatewayMerchantId with the appropriate values for your payment provider. Use the following table to find the specific gateway and gatewayMerchantId values for your payment provider:
The PAYMENT_GATEWAY tokenization type is the most common merchant implementation of the card payment method in the Google Pay API. If your payment provider isn't supported, you might be able to accept Google Pay by a DIRECT integration. For more information, see the Direct tokenization documentation.
Step 3: Define supported payment card networks
Define the card networks accepted by your site. See the following code sample:
The Google Pay API might return cards on file with Google (PAN_ONLY), and/or a device token on an Android device that's authenticated with a 3-D Secure cryptogram (CRYPTOGRAM_3DS). See the following code sample:
For more information, see CardParameters in our Object reference documentation. Also, check with your gateway or processor for the card networks that are supported, and for support for Android device tokens.
Step 4: Describe your allowed payment methods
To describe your allowed payment methods, complete the following steps:
Combine your supported authentication methods and supported card networks in order to describe your site's support for the CARD payment method. See the following code sample:
Extend the base card payment method object to describe information you expect to be returned to your application. Include a description of the tokenized payment data. See the following code sample:
After the Google Pay API JavaScript library loads, initialize a PaymentsClient object. Initial development uses a TEST environment, which returns dummy payment methods that are suitable to reference the structure of a payment response. In this environment, a selected payment method isn't capable of a transaction. See the following code sample.
const paymentsClient = new google.payments.api.PaymentsClient({environment:'TEST'});
For more information about the requirements for a PRODUCTION environment that returns chargeable payment methods, see the Integration checklist.
Step 6: Determine readiness to pay with the Google Pay API
To determine readiness to pay with the Google Pay API, complete the following steps:
Add your allowed payment methods to your base request object. See the following code sample:
Call isReadyToPay() to determine if the Google Pay API is supported by the current device and browser for your specified payment methods. See the following code sample:
paymentsClient.isReadyToPay(isReadyToPayRequest) .then(function(response){ if(response.result){ // add a Google Pay payment button } }) .catch(function(err){ // show error in developer console for debugging console.error(err); });
Step 7: Add a Google Pay payment button
Add a Google Pay payment button to your page to encourage shoppers to check out with payment methods that are supported by the Google Pay API and your site. For more information about available button types, colors, and display requirements, see the Brand guidelines.
See the following payment button code sample:
const button = paymentsClient.createButton({onClick:()=> console.log('TODO: click handler'), allowedPaymentMethods:[]});// make sure to provide an allowed payment method document.getElementById('container').appendChild(button);
Step 8: Create a PaymentDataRequest object
To create a PaymentDataRequest object, complete the following steps:
Build a JavaScript object that describes your site's support for the Google Pay API. For a full list of supported properties, see PaymentDataRequest. See the following code sample:
Add the payment methods supported by your app, such as any configuration of additional data that's expected in the response. See the following code sample:
Provide a user-visible merchant name, and use our TESTmerchantId value when in TEST. For more details, and for information on when to replace the TESTmerchantId value, see MerchantInfo. See the following code sample of a user-visible merchant name:
Step 9: Register an event handler for user gestures
To register an event handler for user gestures, complete the following steps:
Register a click event handler for the purchase button. The event handler calls loadPaymentData() immediately after it interacts with the Google Pay, payment button.
After a Google user grants permission for your site to receive information about the user's selected form of payment and optional contact data, handle the response from the Google Pay API.
Extract the payment token from the paymentData response. If you implement a gateway integration, pass this token to your gateway without any modifications.
paymentsClient.loadPaymentData(paymentDataRequest).then(function(paymentData){ // if using gateway tokenization, pass this token without modification paymentToken = paymentData.paymentMethodData.tokenizationData.token; }).catch(function(err){ // show error in developer console for debugging console.error(err); });
Step 10 (optional): Prefetch payment data before user interaction
To improve execution time, prefetch your website's payment configuration from the Google Pay API before you call loadPaymentData(). See the following example:
Authorize Payments is used to start the payment process and acknowledge a payment's authorization status. To set up Authorize Payments, take the following steps:
The onPaymentAuthorized() callback is invoked with a PaymentData object by Google after a payer approves payment through a user gesture, such as if they click Pay.
The callback returns a Promise<PaymentAuthorizationResult> value. The PaymentAuthorizationResult object has a SUCCESS or ERROR transaction state status. Upon success, the payment sheet is closed successfully. If you encounter an error, the payment sheet renders the error details returned after the payment is processed. The user can change the payment sheet’s payment data and authorize the payment again. See the following code sample:
Step 12 (optional for shipping-enabled): Set up Dynamic Price Updates
Dynamic Price Updates allows a merchant to dynamically update shipping options and transaction information based on a chosen shipping address. Additionally, you can dynamically update transaction information based on a chosen shipping option.
To set up Dynamic Price Updates, take the following steps:
The callback returns a Promise<PaymentDataRequestUpdate>. The PaymentDataRequestUpdate object has new transaction information, shipping options, and a payment data error. This data updates the payment sheet.
Handle any exception cases, such as an unserviceable shipping address or invalid shipping option, directly in the payment sheet. Set up a PaymentDataError object to highlight the reason for the error with an error message to the user. Be sure to include the related intent in the message. For details on how to set up the object and message, see the following code sample:
function onPaymentDataChanged(intermediatePaymentData){ returnnewPromise(function(resolve, reject){
let shippingAddress = intermediatePaymentData.shippingAddress; let shippingOptionData = intermediatePaymentData.shippingOptionData; let paymentDataRequestUpdate ={};
The callback must return a Promise<PaymentDataRequestUpdate>. The PaymentDataRequestUpdate object has new transaction information, shipping options, offer data, and a payment data error. This data updates the payment sheet.
Handle any exception cases, such as an invalid promo code, directly in the payment sheet. Set up a PaymentDataError object to highlight the reason for the error with an error message to the user. Be sure to include the related intent in the message. For details on how to set up the object and message, see the following code sample, which references an object (validPromoCodes) containing the promo code values:
function onPaymentDataChanged(intermediatePaymentData){ returnnewPromise(function(resolve, reject){
let redemptionCodes =[]; let shippingOptionData = intermediatePaymentData.shippingOptionData; let paymentDataRequestUpdate ={}; paymentDataRequestUpdate.newTransactionInfo = getGoogleTransactionInfo();
// ensure that promo codes set is unique if(typeof intermediatePaymentData.offerData !='undefined'){ // convert to set then back to array redemptionCodes =Array.from( newSet(intermediatePaymentData.offerData.redemptionCodes) ); }
// OPTIONAL: ensure that the newest promo code is the only one applied // redemptionCodes = new Array(redemptionCodes[redemptionCodes.length -1]);
The example code blocks in this section show a complete end-to-end example of the Google Pay API JavaScript library tutorial, Authorize Payments, Dynamic Price Updates, and Promo Codes.
Here we will be creating a GET
request REST service which will be world accessible.
Before proceeding we need to take care that the
minimum tools version required is 8.53.
Brief steps:
1. Create a document
for input GET parameters.
2. Create message for
input document for GET parameters.
3. Create an output
XML.
4. Create a new
message for output XML.
5. Create a new REST
Service.
6. Create a new GET
Service Operation.
7. Create a new
Application Package that needs to be used as a Service Operation Handler.
8. Assign the Handler.
9. Enable Anynomous
Node.
10. Test the Operation
from outside PeopleSoft.
Step 1:
Navigation:
Main
Menu->PeopleTools->Documents->Document Builder
Click on “Add a New Value” link here.
Now fill “Package”, “Document” and “Version” and click “Add”.
On Next Page, click on the root of the document and click on the “Add Primitive Child” button below (Purple one). And add the details as in the screenshot. And click “Save”.
Step 2:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Messages
Click on “Add a New Value” link here.
Now fill details as in screenshot and click “Add” and then click “Save”.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document on Fri May 12 2017 18:38:05 GMT+0530 (India Standard Time) -->
<!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->
<xs:element name="REST_TEST_OUTPUT">
<xs:complexType>
<xs:sequence>
<xs:element name="msgdata" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Use this example XML.
Schhema created from:
http://xmlgrid.net/xml2xsd.html
Step 4:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Messages
Click on “Add a New Value” link here.
Now fill “Type”, “Message Name” and “Message Version” and click “Add”.
Fill out the details in “Message Definition” tab as in screenshot below.
Now in schema tab click on “Add Schema”, paste the above schema and click on “OK”.
Now get back to “Message Definition” tab and click “Save”.
Step 5:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Services
Click on “Add a New Value” link here.
Now fill “Service” and check “REST Service” checkbox and click “Add”.
Fill the details as below and click on “Save”. Don’t go of te page yet.
Step 6:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Service Operations
Before going to the navigation above we need to create the REST Service Operation of GET type on the Service page only. Fill the details as in screenshot and click “Add”.
Now it will take you to the Service Operation page. Fill the details as in the screenshots below and click on “Save”.
Now Click on “Service Operation Security” and add the permission list with “Full Access”. I have used “PTPT1000” permission list and will assign “PeopleSoft User” role to user assigned to ANONYMOUS node. And click “Save”.
Step 7:
Now we have to open Application Designer. Create a new Application Package with the code below.
import PS_PT:Integration:IRequestHandler;
class Process implements PS_PT:Integration:IRequestHandler
method Process();
method OnRequest(&_MSG As Message) Returns Message;
method OnError(&pRequestMsg As Message) Returns string;
end-class;
method Process
end-method;
method OnRequest
/+ &_MSG as Message +/
/+ Returns Message +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/
Local Message &request, &response;
&request = &_MSG;
Local Document &reqDOC;
&reqDOC = &request.GetURIDocument();
Local string &name;
Local integer &count;
&name = &reqDOC.GetElement("name").value;
&response = CreateMessage(Operation.REST_TEST_SOP_GET, %IntBroker_Response);
Local XmlDoc &xmlout;
&xmlout = CreateXmlDoc("<?xml version=""1.0""?><REST_TEST_OUTPUT><msgdata>Hello " | &name | "</msgdata></REST_TEST_OUTPUT>");
&response.SetXmlDoc(&xmlout);
Return &response;
end-method;
method OnError
/+ &pRequestMsg as Message +/
/+ Returns String +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnError +/
Return "Error Occured";
end-method;
Step 8:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Service Operations
Open the “Service Operation”, open the “Handlers” tab. put the “Name”, “Type” and “Implementation” as below screenshot. And click on “Details” link.
Put the Handler details as below screenshot. Click “OK” then “Save”.
Step 9:
Navigation:
Main Menu->PeopleTools->Integration Broker->Integration Setup->Nodes
To enable ANONYMOUS Node open it and check the PeopleSoft user assigned to it.
Now Provide the appropriate role to the user which contains permission list which was assigned full access in “Step 6”.
Step 10:
Get the URL from Service Operation page. In my case URL is: