Beispiel #1
0
 def build_request(self, api_result_key, digest_mode):
     request = self.get_request_base_xml(self._operation,
                                         TagConstants.getRefundRequestTag())
     refundRequest = request.find(TagConstants.getDataTag()).find(
         TagConstants.getRefundRequestTag())
     Utils.addChild(refundRequest, TagConstants.getTransactionIDTag(),
                    self._transaction_id)
     Utils.addChild(refundRequest, TagConstants.getOrderIDTag(),
                    self._order_id)
     Utils.addChild(refundRequest, TagConstants.getAmountTag(),
                    self._amount)
     Utils.addChild(refundRequest, TagConstants.getCurrencyTag(),
                    self._currency)
     if self._exponent is not None:
         Utils.addChild(refundRequest, TagConstants.getExponentTag(),
                        self._exponent)
     if self._op_descr is not None:
         Utils.addChild(refundRequest, TagConstants.getOpDescrTag(),
                        self._op_descr)
     if self._options is not None:
         Utils.addChild(refundRequest, TagConstants.getOptionsTag(),
                        self._options)
     mac = request.find(TagConstants.getRequestTag()).find(
         TagConstants.getMACTag())
     mac.text = Encoder.get_mac(self._string_for_mac(), api_result_key,
                                digest_mode)
     return ET.tostring(request, "utf-8", method='xml')
 def __init__(self, operation_xml):
     self.transaction_id = get_tag_value(operation_xml,
                                         TagConstants.getTransactionIDTag())
     self.timestamp_req = get_tag_value(operation_xml,
                                        TagConstants.getTimestampReqTag())
     self.timestamp_elab = get_tag_value(operation_xml,
                                         TagConstants.getTimestampElabTag())
     self.src_type = get_tag_value(operation_xml,
                                   TagConstants.getSrcTypeTag())
     self.amount = get_tag_value(operation_xml, TagConstants.getAmountTag())
     self.result = get_tag_value(operation_xml, TagConstants.getResultTag())
     self.status = get_tag_value(operation_xml, TagConstants.getStatusTag())
     self.op_descr = get_tag_value(operation_xml,
                                   TagConstants.getOpDescrTag())
     self.operation = get_tag_value(operation_xml,
                                    TagConstants.getOperationTag())
     auth = operation_xml.find(TagConstants.getAuthorizationTag())
     if auth is not None:
         self.authorization = Authorization(auth)
Beispiel #3
0
def getOperationStringForMac(operationXml):
    stringForMac = operationXml.find(TagConstants.getTransactionIDTag()).text
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getTimestampReqTag()).text)
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getTimestampElabTag()).text)
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getSrcTypeTag()).text)
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getAmountTag()).text)
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getResultTag()).text)
    stringForMac = append_field_for_verification(
        stringForMac,
        operationXml.find(TagConstants.getStatusTag()).text)
    return append_optional_field_for_verification(
        stringForMac, operationXml.find(TagConstants.getOpDescrTag()))
Beispiel #4
0
    def build_request(self, api_result_key, digest_mode):
        request = self.get_request_base_xml(
            self._operation, TagConstants.getAuthorizationRequestTag())
        authorization = request.find(TagConstants.getDataTag()).find(
            TagConstants.getAuthorizationRequestTag())

        Utils.addChild(authorization, TagConstants.getOrderIDTag(),
                       self._order_id)
        Utils.addChild(authorization, TagConstants.getPanTag(), self._pan)
        Utils.addChild(authorization, TagConstants.getExpDateTag(),
                       self._exp_date)
        Utils.addChild(authorization, TagConstants.getAmountTag(),
                       self._amount)
        Utils.addChild(authorization, TagConstants.getCurrencyTag(),
                       self._currency)
        Utils.addOptionalChild(authorization, TagConstants.getExponentTag(),
                               self._exponent)
        Utils.addChild(authorization, TagConstants.getAccountingModeTag(),
                       self._accounting_mode)
        Utils.addChild(authorization, TagConstants.getNetworkTag(),
                       self._network)

        # OPTIONAL CHILD
        Utils.addOptionalChild(authorization, TagConstants.getCVV2Tag(),
                               self._cvv2)
        Utils.addOptionalChild(authorization, TagConstants.getEmailCHTag(),
                               self._email_ch)
        Utils.addOptionalChild(authorization, TagConstants.getUseridTag(),
                               self._user_id)
        Utils.addOptionalChild(authorization, TagConstants.getAcquirerTag(),
                               self._acquirer)
        Utils.addOptionalChild(authorization, TagConstants.getIpAddressTag(),
                               self._ip_address)
        Utils.addOptionalChild(authorization,
                               TagConstants.getUserAuthFlagTag(),
                               self._usr_auth_flag)

        Utils.addOptionalChild(authorization, TagConstants.getOpDescrTag(),
                               self._op_descr)
        Utils.addOptionalChild(authorization, TagConstants.getOptionsTag(),
                               self._options)
        Utils.addOptionalChild(authorization, TagConstants.getAntiFraudTag(),
                               self._anti_fraud)
        Utils.addOptionalChild(authorization, TagConstants.getProductRefTag(),
                               self._product_ref)
        Utils.addOptionalChild(authorization, TagConstants.getNameTag(),
                               self._name)
        Utils.addOptionalChild(authorization, TagConstants.getSurnameTag(),
                               self._surname)

        Utils.addOptionalChild(authorization, TagConstants.getTaxIDTag(),
                               self._tax_id)
        Utils.addOptionalChild(authorization, TagConstants.getTRecurrTag(),
                               self._tRecurr)
        Utils.addOptionalChild(authorization, TagConstants.getCRecurrTag(),
                               self._cRecurr)
        Utils.addOptionalChild(authorization,
                               TagConstants.getInstallmentsNumberTag(),
                               self._installments_number)

        Utils.addOptionalChild(authorization,
                               TagConstants.getCreatePanAliasTag(),
                               self._create_pan_alias)

        mac = request.find(TagConstants.getRequestTag()).find(
            TagConstants.getMACTag())
        mac.text = Encoder.get_mac(self._string_for_mac(), api_result_key,
                                   digest_mode)
        return ET.tostring(request, "utf-8", method='xml')