diff --git a/paypal/standard/forms.py b/paypal/standard/forms.py index e9992a5..63a7da4 100644 --- a/paypal/standard/forms.py +++ b/paypal/standard/forms.py @@ -4,7 +4,8 @@ from django.conf import settings from django.utils.safestring import mark_safe from paypal.standard.conf import * -from paypal.standard.widgets import ValueHiddenInput, ReservedValueHiddenInput +from paypal.standard.widgets import (ValueHiddenInput, ReservedValueHiddenInput, + ItemOptionsInput) from paypal.standard.conf import (POSTBACK_ENDPOINT, SANDBOX_POSTBACK_ENDPOINT, RECEIVER_EMAIL) @@ -59,6 +60,7 @@ class PayPalPaymentsForm(forms.Form): item_name = forms.CharField(widget=ValueHiddenInput()) item_number = forms.CharField(widget=ValueHiddenInput()) quantity = forms.CharField(widget=ValueHiddenInput()) + item_options = forms.ChoiceField(widget=ItemOptionsInput()) # Subscription Related. a1 = forms.CharField(widget=ValueHiddenInput()) # Trial 1 Price @@ -99,6 +101,12 @@ def __init__(self, button_type="buy", *args, **kwargs): super(PayPalPaymentsForm, self).__init__(*args, **kwargs) self.button_type = button_type + # If item_options have been specified, populate the item_options select + # with the given choices. + item_options = kwargs['initial'].get('item_options', ()) + if item_options: + self.fields['item_options'].choices = item_options + def render(self): return mark_safe(u"""