CreateProfile Method
This method creates a new recurring payments profile.
Syntax
recurringpayments.createProfile([callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
This method should be called to create a new recurring payments profile. It must be called for each profile that should be created.
Set the options for the profile before calling CreateProfile. The profile must contain values for BillingFrequency, BillingPeriod, BillingAmount, and BillingStartDate.
There are two payment options for creating a new profile.
DirectPayment Option
The profile may be created with a credit card specified by the Card property.
ExpressCheckout Option
This option requires that a billing agreement has already been setup using the ExpressCheckout class. There must be a billing agreement for each profile that is created. The Description must be the same as the description specified in the BillingAgreements property. The Token also must be the response token as returned from the SetCheckout method.
The following example shows how to successfully use ExpressCheckout to create a new recurring
payments profile:
ExpressCheckout1.OrderTotal =
"0"
ExpressCheckout1.ReturnURL =
"http://localhost"
ExpressCheckout1.CancelURL =
"http://localhost"
ExpressCheckout1.BillingAgreements =
new
String[1]
ExpressCheckout1.BillingAgreements[0] =
"My Description"
ExpressCheckout1.SetCheckout()
URL: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_customer-billing-agreement&token=PUT_TOKEN_HERE
Once the customer has been redirected to the above URL and accepted the billing agreement, the
following code will create a new profile:
RecurringPayments1.Token = ExpressCheckout1.ResponseToken
RecurringPayments1.Description =
"My Description"
RecurringPayments1.BillingDetails.Period = BillingPeriods.bpMonth
RecurringPayments1.BillingDetails.Frequency =
"12"
RecurringPayments1.BillingDetails.Amount =
"12.01"
RecurringPayments1.BillingDetails.StartDate =
"2009-08-25T07:00:00Z"
RecurringPayments1.CreateProfile()