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 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 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
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 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: return False else: return True
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) 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