Re-work API for payment settings fields

This commit is contained in:
Raphael Michel
2015-03-15 19:02:38 +01:00
parent b6bda537e8
commit 41f816388b
5 changed files with 81 additions and 59 deletions

View File

@@ -22,31 +22,36 @@ class Paypal(BasePaymentProvider):
identifier = 'paypal'
verbose_name = _('PayPal')
settings_form_fields = OrderedDict([
('endpoint',
forms.ChoiceField(
label=_('Endpoint'),
initial='live',
choices=(
('live', 'Live'),
('sandbox', 'Sandbox'),
),
required=False
)),
('client_id',
forms.CharField(
label=_('Client ID'),
required=False
)),
('secret',
forms.CharField(
label=_('Secret'),
required=False
))
])
checkout_form_fields = OrderedDict([
])
@property
def settings_form_fields(self):
return OrderedDict(
list(super().settings_form_fields.items()) + [
('endpoint',
forms.ChoiceField(
label=_('Endpoint'),
initial='live',
choices=(
('live', 'Live'),
('sandbox', 'Sandbox'),
),
required=False
)),
('client_id',
forms.CharField(
label=_('Client ID'),
required=False
)),
('secret',
forms.CharField(
label=_('Secret'),
required=False
))
]
)
def init_api(self):
paypalrestsdk.set_config(
mode="sandbox" if "sandbox" in self.settings.get('endpoint') else 'live',