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 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)
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
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
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
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
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
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)
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
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
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) return not nvp_obj.flag
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
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
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
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) # @@@ 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 not nvp_obj.flag
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
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") return self._fetch(params, required, defaults)
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
def _recurring_setExpressCheckout_adapter(self, params): """ The recurring payment interface to SEC is different than the recurring payment interface to ECP. This adapts a normal call to look like a SEC call. """ params['l_billingtype0'] = "RecurringPayments" params['l_billingagreementdescription0'] = params['desc'] REMOVE = L("billingfrequency billingperiod profilestartdate desc") for k in params.keys(): if k in REMOVE: del params[k] return params
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