Esempio n. 1
0
    def setExpressCheckout(self, params):
        """
        Initiates an Express Checkout transaction.
        Optionally, the SetExpressCheckout API operation can set up billing agreements for
        reference transactions and recurring payments.
        Returns a NVP instance - check for token and payerid to continue!
        """
        if "amt" in params:
            import warnings

            warnings.warn(
                "'amt' has been deprecated. 'paymentrequest_0_amt' "
                "should be used instead.", DeprecationWarning)
            # Make a copy so we don't change things unexpectedly
            params = params.copy()
            params.update({'paymentrequest_0_amt': params['amt']})
            del params['amt']
        if self._is_recurring(params):
            params = self._recurring_setExpressCheckout_adapter(params)

        defaults = {"method": "SetExpressCheckout", "noshipping": 1}
        required = ["returnurl", "cancelurl", "paymentrequest_0_amt"]
        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
        return nvp_obj
Esempio n. 2
0
    def manangeRecurringPaymentsProfileStatus(self,
                                              params,
                                              fail_silently=False):
        """
        Requires `profileid` and `action` params.
        Action must be either "Cancel", "Suspend", or "Reactivate".
        """
        defaults = {"method": "ManageRecurringPaymentsProfileStatus"}
        required = L("profileid action")

        nvp_obj = self._fetch(params, required, defaults)

        # TODO: This fail silently check should be using the error code, but its not easy to access
        if not nvp_obj.flag or (
                fail_silently and nvp_obj.flag_info ==
                'Invalid profile status for cancel action; profile should be active or suspended'
        ):
            if params['action'] == 'Cancel':
                recurring_cancel.send(sender=nvp_obj)
            elif params['action'] == 'Suspend':
                recurring_suspend.send(sender=nvp_obj)
            elif params['action'] == 'Reactivate':
                recurring_reactivate.send(sender=nvp_obj)
        else:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 3
0
 def getExpressCheckoutDetails(self, params):
     defaults = {"method": "GetExpressCheckoutDetails"}
     required = L("token")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     return nvp_obj
Esempio n. 4
0
 def doDirectPayment(self, params):
     """Call PayPal DoDirectPayment method."""
     defaults = {"method": "DoDirectPayment", "paymentaction": "Sale"}
     required = [
         "creditcardtype",
         "acct",
         "expdate",
         "cvv2",
         "ipaddress",
         "firstname",
         "lastname",
         "street",
         "city",
         "state",
         "countrycode",
         "zip",
         "amt",
     ]
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
     payment_was_successful.send(sender=nvp_obj, **params)
     # @@@ Could check cvv2match / avscode are both 'X' or '0'
     # qd = django.http.QueryDict(nvp_obj.response)
     # if qd.get('cvv2match') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid cvv2match: %s" % qd.get('cvv2match')
     # if qd.get('avscode') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid avscode: %s" % qd.get('avscode')
     return nvp_obj
Esempio n. 5
0
    def createRecurringPaymentsProfile(self, params, direct=False):
        """
        Set direct to True to indicate that this is being called as a directPayment.
        Returns True PayPal successfully creates the profile otherwise False.
        """
        defaults = {"method": "CreateRecurringPaymentsProfile"}
        required = [
            "profilestartdate", "billingperiod", "billingfrequency", "amt"
        ]

        # Direct payments require CC data
        if direct:
            required + [
                "creditcardtype", "acct", "expdate", "firstname", "lastname"
            ]
        else:
            required + ["token", "payerid"]

        nvp_obj = self._fetch(params, required, defaults)

        # Flag if profile_type != ActiveProfile
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
        payment_profile_created.send(sender=nvp_obj, **params)
        return nvp_obj
Esempio n. 6
0
    def createRecurringPaymentsProfile(self,
                                       params,
                                       direct=False,
                                       request=None):
        """
        Set direct to True to indicate that this is being called as a directPayment.
        Returns True PayPal successfully creates the profile otherwise False.
        """
        defaults = {"method": "CreateRecurringPaymentsProfile"}
        required = L("profilestartdate billingperiod billingfrequency amt")

        # Direct payments require CC data
        if direct:
            required + L("creditcardtype acct expdate firstname lastname")
        else:
            required + L("token payerid")

        nvp_obj = self._fetch(params, required, defaults)

        # Flag if profile_type != ActiveProfile
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        payment_profile_created.send(sender=self,
                                     nvp_obj=nvp_obj,
                                     params=params,
                                     request=request)
        return nvp_obj
    def doExpressCheckoutPayment(self, params):
        """
        Check the dude out:
        """
        if "amt" in params:
            import warnings

            warnings.warn(
                "'amt' has been deprecated. 'paymentrequest_0_amt' "
                "should be used instead.", DeprecationWarning)
            # Make a copy so we don't change things unexpectedly
            params = params.copy()
            params.update({'paymentrequest_0_amt': params['amt']})
            del params['amt']
        defaults = {
            "method": "DoExpressCheckoutPayment",
            "paymentaction": "Sale"
        }
        required = [
            "returnurl", "cancelurl", "paymentrequest_0_amt", "token",
            "payerid"
        ]
        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        payment_was_successful.send(sender=nvp_obj, **params)
        return nvp_obj
Esempio n. 8
0
    def setExpressCheckout(self, params):
        """
        Initiates an Express Checkout transaction.
        Optionally, the SetExpressCheckout API operation can set up billing agreements for
        reference transactions and recurring payments.
        Returns a NVP instance - check for token and payerid to continue!
        """
        if self._is_recurring(params):
            params = self._recurring_setExpressCheckout_adapter(params)

        defaults = {
            "method":
            "SetExpressCheckout",
            "noshipping":
            1,
            "PAYMENTREQUEST_0_PAYMENTACTION":
            'Authorization',
            #                    'PAYMENTREQUEST_0_CURRENCYCODE':'EUR',
            #                    'CURRENCYCODE':'EUR',
            'HDRIMG':
            'https://static.e-junkie.com/sslpic/64123.1c8bb1d04a97bc111163dcfaa2c5f109.jpg',
            #                    "paymentaction":'Sale'
        }
        required = L("returnurl cancelurl")
        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 9
0
    def refundTransaction(self, params):
        defaults = {"method": "RefundTransaction"}
        required = L("transactionid")

        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
Esempio n. 10
0
    def updateRecurringPaymentsProfile(self, params):
        defaults = {"method": "UpdateRecurringPaymentsProfile"}
        required = L("profileid")

        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 11
0
    def getTransactionDetails(self, params):
        defaults = {"method": "GetTransactionDetails"}
        required = L("transactionid")

        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 12
0
 def refundTransaction(self, params):
     """Call PayPal RefundTransaction method."""
     defaults = {"method": "RefundTransaction", "refundtype": "Full"}
     required = L("transactionid")
     optional = L("invoiceid amt currencycode note")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
Esempio n. 13
0
 def doReauthorization(self, params):
     """Call PayPal DoReauthorization method."""
     defaults = {"method": "DoReauthorization"}
     required = L("authorizationid amt")
     optional = L("currencycode")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     return nvp_obj
Esempio n. 14
0
 def doVoid(self, params):
     """Call PayPal DoVoid method."""
     defaults = {"method": "DoVoid"}
     required = L("authorizationid")
     optional = L("note")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     return nvp_obj
Esempio n. 15
0
 def doCapture(self, params):
     """Call PayPal DoCapture method."""
     defaults = {"method": "DoCapture", "completetype": "NotComplete"}
     required = L("authorizationid amt")
     optional = L("currencycode invnum note softdescriptor")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     payment_was_successful.send(params)
     return nvp_obj
Esempio n. 16
0
 def doVoid(self, params):
     """
     Check the dude out:
     """
     defaults = {"method": "DoVoid"}
     required = L("AUTHORIZATIONID")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     return nvp_obj
Esempio n. 17
0
 def api_call(self, method, params, extra_requirements=None):
     assert method in API_METHODS
     params['METHOD'] = method
     nvp = self._fetch(params, extra_requirements=extra_requirements)
     if nvp.flag:
         raise PayPalFailure(nvp.flag_info)
     signal = API_METHODS[method].get('signal', None)
     if signal:
         signal.send(self, params=params, nvp=nvp)
     return nvp
Esempio n. 18
0
 def createBillingAgreement(self, params):
     """
     Create a billing agreement for future use, without any initial payment
     """
     defaults = {"method": "CreateBillingAgreement"}
     required = ["token"]
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
     return nvp_obj
Esempio n. 19
0
 def doExpressCheckoutPayment(self, params):
     """
     Check the dude out:
     """
     defaults = {"method": "DoExpressCheckoutPayment", "paymentaction": "Sale"}
     required = L("returnurl cancelurl amt token payerid")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     payment_was_successful.send(params)
     return nvp_obj
Esempio n. 20
0
    def getRecurringPaymentsProfileDetails(self, params):
        defaults = {"method": "GetRecurringPaymentsProfileDetails"}
        required = []

        # Manually check for profile and ensure it's not None
        if params.get('profileid', None) is None:
            raise PayPalError("Missing required param: 'profileid'")

        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 21
0
 def doExpressCheckoutPayment(self, params):
     """
     Check the dude out:
     """
     defaults = {
         "method": "DoExpressCheckoutPayment",
         "paymentaction": "Sale"
     }
     required = ["paymentrequest_0_amt", "token", "payerid"]
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
     return nvp_obj
Esempio n. 22
0
 def doCapture(self, params):
     """
     Check the dude out:
     """
     defaults = {
         "method": "DoCapture",
         "COMPLETETYPE": "Complete",
     }
     required = L("AMT AUTHORIZATIONID CURRENCYCODE")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     return nvp_obj
Esempio n. 23
0
 def doReferenceTransaction(self, params):
     """
     Check out using a previous transaction (used for one-click)
     """
     defaults = {
         "method": "DoReferenceTransaction",
         "paymentaction": "Sale"
     }
     required = L("returnurl cancelurl amt token referenceid")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     payment_was_successful.send(params)
     return nvp_obj
Esempio n. 24
0
    def doReferenceTransaction(self, params):
        """
        Process a payment from a buyer's account, identified by a previous
        transaction.
        The `paymentaction` param defaults to "Sale", but may also contain the
        values "Authorization" or "Order".
        """
        defaults = {"method": "DoReferenceTransaction",
                    "paymentaction": "Sale"}
        required = ["referenceid", "amt"]

        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
        return nvp_obj
Esempio n. 25
0
 def doDirectPayment(self, params):
     """Call PayPal DoDirectPayment method."""
     defaults = {"method": "DoDirectPayment", "paymentaction": "Sale"}
     required = L("creditcardtype acct expdate cvv2 ipaddress firstname lastname street city state countrycode zip amt")
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     payment_was_successful.send(sender=self, request_params=params, paypal_nvp=nvp_obj)
     # @@@ Could check cvv2match / avscode are both 'X' or '0'
     # qd = django.http.QueryDict(nvp_obj.response)
     # if qd.get('cvv2match') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid cvv2match: %s" % qd.get('cvv2match')
     # if qd.get('avscode') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid avscode: %s" % qd.get('avscode')
     return nvp_obj
Esempio n. 26
0
    def setExpressCheckout(self, params):
        """
        Initiates an Express Checkout transaction.
        Optionally, the SetExpressCheckout API operation can set up billing agreements for
        reference transactions and recurring payments.
        Returns a NVP instance - check for token and payerid to continue!
        """
        if self._is_recurring(params):
            params = self._recurring_setExpressCheckout_adapter(params)

        defaults = {"method": "SetExpressCheckout", "noshipping": 1}
        required = L("returnurl cancelurl amt")
        nvp_obj = self._fetch(params, required, defaults)
        if nvp_obj.flag:
            raise PayPalFailure(nvp_obj.flag_info)
        return nvp_obj
Esempio n. 27
0
    def manangeRecurringPaymentsProfileStatus(self,
                                              params,
                                              fail_silently=False):
        """
        Requires `profileid` and `action` params.
        Action must be either "Cancel", "Suspend", or "Reactivate".
        """
        defaults = {"method": "ManageRecurringPaymentsProfileStatus"}
        required = ["profileid", "action"]

        nvp_obj = self._fetch(params, required, defaults)

        # TODO: This fail silently check should be using the error code, but its not easy to access
        flag_info_test_string = "Invalid profile status for cancel action; profile should be active or suspended"
        if nvp_obj.flag and not (fail_silently and nvp_obj.flag_info
                                 == flag_info_test_string):
            raise PayPalFailure(nvp_obj.flag_info, nvp=nvp_obj)
        return nvp_obj
Esempio n. 28
0
 def doDirectPayment(self, params):
     """Call PayPal DoDirectPayment method."""
     defaults = {"method": "DoDirectPayment", "paymentaction": "Sale"}
     required = L(
         "ipaddress creditcardtype acct expdate cvv2 firstname lastname street city state countrycode zip amt"
     )
     optional = L(
         "returnfmfdetails startdate issuenumber email street2 shiptophonenum currencycode itemamt shippingamt handlingamt taxamt desc custom invnum buttonsource notifyurl"
     )
     nvp_obj = self._fetch(params, required, defaults)
     if nvp_obj.flag:
         raise PayPalFailure(nvp_obj.flag_info)
     if params["paymentaction"] == "Sale":
         payment_was_successful.send(params)
     # @@@ Could check cvv2match / avscode are both 'X' or '0'
     # qd = django.http.QueryDict(nvp_obj.response)
     # if qd.get('cvv2match') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid cvv2match: %s" % qd.get('cvv2match')
     # if qd.get('avscode') not in ['X', '0']:
     #   nvp_obj.set_flag("Invalid avscode: %s" % qd.get('avscode')
     return nvp_obj