コード例 #1
0
    def list_recurring_details(self, request="", **kwargs):

        action = "listRecurringDetails"

        if validation.check_in(request, action):
            return self.client.call_api(request, self.service, action,
                                        **kwargs)
コード例 #2
0
    def hpp_payment(self, request="", skipDetails=None, **kwargs):

        if skipDetails == True:
            action = "skipDetails"
        else:
            action = "select"

        if validation.check_in(request, action):

            if action == "skipDetails":
                if "issuerId" not in request:
                    request['issuerId'] = ""
            if type(request['sessionValidity']) is not str:
                raise TypeError(
                    'HPP: sessionValidity must be type of str, use datetime.strftime to convert and format.'
                )
            if all(k in request for k in ("shopperEmail", "shopperReference",
                                          "recurringContract")):
                recc = request['recurringContract']
                if recc != 'ONECLICK' and recc != 'RECURRING' and recc != 'ONECLICK,RECURRING':
                    raise ValueError(
                        "HPP: recurringContract must be on of the following values: 'ONECLICK', 'RECURRING', 'ONECLICK,RECURRING'"
                    )

            result = self.client.hpp_payment(request, action)
            return result
コード例 #3
0
    def disable(self, request="", **kwargs):

        action = "disable"

        if validation.check_in(request, action):
            if 'recurringDetailReference' not in request:
                raise ValueError(
                    "Include a 'recurringDetailReference' to disable a specific recurring contract."
                )
            else:
                return self.client.call_api(request, self.service, action,
                                            **kwargs)
コード例 #4
0
    def refund(self, request="", **kwargs):

        action = "refund"

        if validation.check_in(request, action):
            if request['modificationAmount']['value'] == "" or request[
                    'modificationAmount']['value'] == "0":
                raise ValueError(
                    "To refund this payment, provide the original value. Set the value to less than the original amount, to partially refund this payment."
                )
            else:
                return self.client.call_api(request, self.service, action,
                                            **kwargs)
コード例 #5
0
    def directory_lookup(self, request="", **kwargs):

        action = "directory"

        if validation.check_in(request, action):
            try:
                datetime.datetime.strptime(request['sessionValidity'],
                                           '%Y-%m-%dT%H:%M:%SZ')
            except ValueError:
                raise ValueError(
                    "Incorrect date format, should be Y-m-dH:M:SZ, use datetime.strftime('%Y-%m-%dT%H:%M:%SZ') to format a datetime object."
                )

            return self.client.call_hpp(request, action)
コード例 #6
0
    def capture(self, request="", **kwargs):

        action = "capture"

        if validation.check_in(request, action):
            if request['modificationAmount']["value"] == "" or request[
                    'modificationAmount']['value'] == "0":
                raise ValueError(
                    "Set the 'modificationAmount' to the original transaction amount, or less for a partial capture. modificationAmount should be an object with the following keys: {'currency':,'value':}"
                )
            if request['originalReference'] == "":
                raise ValueError(
                    "Set the 'originalReference' to the psp reference of the transaction to be modified"
                )

            response = self.client.call_api(request, self.service, action,
                                            **kwargs)
            return response
コード例 #7
0
    def authorise(self, request="", **kwargs):

        action = "authorise"

        if validation.check_in(request, action):
            if 'shopperEmail' in request:
                if request['shopperEmail'] == '':
                    raise ValueError(
                        'shopperEmail must contain the shopper email when authorising recurring contracts.'
                    )
            if 'shopperReference' in request:
                if request['shopperReference'] == '':
                    raise ValueError(
                        'shopperReference must contain the shopper name when authorising recurring contracts.'
                    )

            return self.client.call_api(request, self.service, action,
                                        **kwargs)
コード例 #8
0
    def cancel_or_refund(self, request="", **kwargs):
        action = "cancelOrRefund"

        if validation.check_in(request, action):
            return self.client.call_api(request, self.service, action,
                                        **kwargs)
コード例 #9
0
    def authorise3d(self, request="", **kwargs):
        action = "authorise3d"

        if validation.check_in(request, action):
            return self.client.call_api(request, self.service, action,
                                        **kwargs)