may i please give someone all my project files including the certificates,APIKEY sharedsecret
and they send it back to me without this annoying error which av been getting for the last two weeks
am ready to give everything
HTTP/1.1 401 Unauthorized
Server: Apache
X-SERVED-BY: l73c038
X-CORRELATION-ID: 1527021004_461_77_l73c038_VDP_ARM
X-APP-STATUS: 401
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=2592000;includeSubdomains
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: -1
Content-Type: application/json;charset=UTF-8
Content-Length: 112
Date: Tue, 22 May 2018 20:30:04 GMT
Connection: keep-alive
{"responseStatus":{"code":"9101","severity":"ERROR","info":"","status":401,"message":"Token Validation Failed"}}
Hi @ezamarichard,
Please use the below updated groovy script and Request Pay load and let me know if this works. You'll see some green text. Please subsitute the green text for your project credentials that you can retrieve when you can access from your VDP project dashboard.
Groovy Script
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
def hmac(String secretKey, String data) {
Mac mac = Mac.getInstance("HmacSHA256")
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256")
mac.init(secretKeySpec)
byte[] digest = mac.doFinal(data.getBytes())
return digest
}
def APIKey = 'Enter Your API Key Here'
def sharedSecret = 'Enter Shared Secret'
def URI = "v2/payments"
def QS = "apikey="+APIKey
def timeStampUTC = String.valueOf(System.currentTimeMillis().intdiv(1000L))
def payload = '{ "clientReferenceInformation": { "code": "TC50171_3" }, "processingInformation": { "commerceIndicator": "internet" },"aggregatorInformation": { "subMerchant": { "cardAcceptorID": "1234567890", "country": "US", "phoneNumber": "650-432-0000", "address1":"900 Metro Center", "postalCode": "94404-2775", "locality": "Foster City", "name": "Visa Inc", "administrativeArea": "CA", "region":"PEN", "email": "test@cybs.com" }, "name": "V-Internatio", "aggregatorID": "123456789" }, "orderInformation": { "billTo": { "country":"US", "lastName": "VDP", "address2": "Address 2", "address1": "201 S. Division St.", "postalCode": "48104-2201", "locality": "Ann Arbor","administrativeArea": "MI", "firstName": "RTS", "phoneNumber": "999999999", "district": "MI", "buildingNumber": "123", "company": "Visa","email": "test@cybs.com" }, "amountDetails": { "totalAmount": "102.21", "currency": "USD" } }, "paymentInformation": { "card": {"expirationYear": "2031", "number": "5555555555554444", "securityCode": "123", "expirationMonth": "12", "type": "002" } } }'
def HMACDigest = hmac(sharedSecret, timeStampUTC + URI + QS + payload)
def encodedDigest = HMACDigest.encodeHex().toString()
def XPayToken = "xv2:"+ timeStampUTC + ":" + encodedDigest
testRunner.testCase.setPropertyValue("xpayToken", XPayToken)
log.info(XPayToken)
Request Payload
{ "clientReferenceInformation": { "code": "TC50171_3" }, "processingInformation": { "commerceIndicator": "internet" },"aggregatorInformation": { "subMerchant": { "cardAcceptorID": "1234567890", "country": "US", "phoneNumber": "650-432-0000", "address1":"900 Metro Center", "postalCode": "94404-2775", "locality": "Foster City", "name": "Visa Inc", "administrativeArea": "CA", "region":"PEN", "email": "test@cybs.com" }, "name": "V-Internatio", "aggregatorID": "123456789" }, "orderInformation": { "billTo": { "country":"US", "lastName": "VDP", "address2": "Address 2", "address1": "201 S. Division St.", "postalCode": "48104-2201", "locality": "Ann Arbor","administrativeArea": "MI", "firstName": "RTS", "phoneNumber": "999999999", "district": "MI", "buildingNumber": "123", "company": "Visa","email": "test@cybs.com" }, "amountDetails": { "totalAmount": "102.21", "currency": "USD" } }, "paymentInformation": { "card": {"expirationYear": "2031", "number": "5555555555554444", "securityCode": "123", "expirationMonth": "12", "type": "002" } } }