Re: Cybersource payments Error

simplux
Regular Visitor

Cybersource payments Error

Hello I am integrating to the cybersopurce payments api I have successfully managed to generate the x-pay token however when performing the POST request an error 502 is experienced

"{\"submitTimeUtc\":\"2018-06-03T04:25:21Z\",\"status\":\"SERVER_ERROR\",\"reason\":\"SYSTEM_ERROR\",\"message\":\"Request failed due to unknown system error.\"}

below is my code

class CyberSource:
    
    def __init__(self):

        self.url = "https://sandbox.api.visa.com/cybersource/v2/payments"
        self.apikey = settings.VISA_API_KEY
        self.SharedSecret = settings.VISA_SHARED_KEY
        self.sandbox= "https://sandbox.api.visa.com"

    def processPayment(self):
        """
          
        """
        resource_path = "v2/payments"
        authentication = Auth()
        querystring = "apikey="+settings.VISA_API_KEY
        payload = json.dumps({
                "clientReferenceInformation": {
                    "code": "12QW12_RWE121"
                },
                "orderInformation": {
                    "amountDetails": {
                        "totalAmount": "102.21",
                        "currency": "USD"
                    },
                    "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"
                    }
                },

                "paymentInformation": {
                    "card": {
                        "expirationYear": "2031",
                        "number": "5555555555554444",
                        "securityCode": "123",
                        "expirationMonth": "12",
                        "type": "002"
                    }
                },
            })
        x_pay_token = authentication._get_x_pay_token(self.SharedSecret, resource_path, querystring , payload)
        headers = {
            "Accept" :"application/json",
            "X-PAY-TOKEN" : x_pay_token
        }

        r = requests.post(self.url+"?apikey="+self.apikey,
                headers=headers,
                data = payload
                )

        return r

and the x_pay_token generator

  def _get_x_pay_token(self, shared_secret, resource_path, query_string, body):      
        timestamp = str(timegm(datetime.utcnow().timetuple()))      
        pre_hash_string = timestamp + resource_path + query_string + body      
        hash_string = hmac.new(shared_secret.encode('utf-8'),  msg=pre_hash_string.encode('utf-8'), digestmod=sha256).hexdigest()      
        return 'xv2:' + timestamp + ':' + hash_string

any help would be much appreciated

1 REPLY 1
API_Products
Visa Developer Support Specialist

Re: Cybersource payments Error

Hi @simplux,

 

The 502 error could be indicating that there was a hiccup with the connectivity or there could be some type of network issue. Can you please try again and let me know if the problem persists? Please check to see if your browser, computer and network are functioning properly. Also, check to see that your firewall is allowing traffic flow.

 

If the issue persists, please provide more information on the error you have received. Please send response request of the error received, screenshots and the Correlation ID. Please let us know if you have other questions.

Below are the steps to get the Correlation ID using a Google Chrome browser.
1>Open Chrome menu.
2>Click on More tools then Developer tools.
3>Check the box to Preserve Log for the Network Tab.
4>Then try to click on the add API link.
5>You can find the Correlation ID in the network log for add API call.

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.