import ibilling.client.* class Scenario1 { static void main(args) { //Set up clients' settings def config = [:] config[SessionConnection.PROCESSOR_HOST] = "http://server.ibillingclient.org/ibilling/xmlhttps" //Amount to be used for test transactions that are processed to validate new payment options; optional config[SessionConnection.PAYMENT_OPTION_VERIFICATION_AMOUNT] = 99 //Set the value to true to view XML exchanged between your client and the server config[SessionConnection.DEBUG] = true //Data for increased fraud protection, all of these values are optional //Domain name of user's e-mail (user on behalf of whom the transaction is processed) config[SessionConnection.CLIENT_EMAIL_DOMAIN] = "hotmail.com" //IP Address of the user's machine (user on behalf of whom the transaction is processed) config[SessionConnection.CLIENT_IP_ADDRESS] = "145.21.0.1" //Full e-mail address of the user as MD5 (user on behalf of whom the transaction is processed) config[SessionConnection.CLIENT_EMAIL_ENCODED] = "8d89c3087cc6cb98793ab7c0f5658c56" //Full user name of the user as MD5 (user on behalf of whom the transaction is processed) config[SessionConnection.CLIENT_USER_NAME_ENCODED] = "435e0648d634175c46bd40ac366545a8" //Password of the user as MD5 (user on behalf of whom the transaction is processed) config[SessionConnection.CLIENT_PASSWORD_ENCODED] = "5f4dcc3b5aa765d61d8327deb882cf99" //Login def session = Session.login(2000, "welcome", config) //Create customer account def customerAccount = session.createCustomerAccount() //code is optinal; if you specify the value, make sure the code is unique customerAccount.code = "groovy.ca-1" customerAccount.merchantAccountCode = 2001 customerAccount.firstName = "John" customerAccount.lastName = "Smith" customerAccount.type = CustomerAccountType.Male customerAccount.homePhone = "2129856472" customerAccount.email = "test@yahoo.com" customerAccount.street1 = "233 12th Street" customerAccount.city = "Honolulu" customerAccount.state = "CA" customerAccount.zipCode = "31904" //Create payment option def paymentOption = customerAccount.createPaymentOption() //code is optinal; if you specify the value, make sure the code is unique paymentOption.code = "groovy.po-1" paymentOption.holderName = "John Smith" paymentOption.number = "4111111111111111" //expiration date paymentOption.accessory = "1209" paymentOption.street1 = "233 12th Street" paymentOption.city = "Honolulu" paymentOption.state = "CA" paymentOption.zipCode = "31904" //Create payment plan def paymentPlan = customerAccount.createPaymentPlan() //code is optinal; if you specify the value, make sure the code is unique paymentPlan.code = "groovy.pp-1" //all amounts are in cents paymentPlan.amount = 5000 //Item Codes must be setup in portal prior to being used paymentPlan.itemCode = "Membership" paymentPlan.type = PaymentPlanType.Fixed //Billing Cycle codes must be setup in portal prior to being used paymentPlan.billingCycleCode = "M03" //Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed. //paymentPlan.firstBillingDate = date paymentPlan.add(0, 12, false) // Create invoice for downpayment def revenueTransaction = customerAccount.createRevenueTransaction() //code is optinal; if you specify the value, make sure the code is unique revenueTransaction.code = "groovy.rt-1" //all amounts are in cents revenueTransaction.amount = 10000 //Item Codes must be setup in portal prior to being used revenueTransaction.itemCode = "Membership" //Type of transaction revenueTransaction.accountActivityType = AccountActivityType.Invoice //Create payment for downpayment def transaction = customerAccount.createAssetTransaction() //code is optinal; if you specify the value, make sure the code is unique transaction.code = "groovy.at-1" //all amounts are in cents transaction.amount = 10000 transaction.transactionType = AssetTransactionType.Cash transaction.accountActivityType = AccountActivityType.Payment //Mark object for persistence session.save(customerAccount) //Synchronize changes with the server try{ session.synchronize() } catch(Exception ex){ //Be sure to properly handle exception, this is just a sample solution println(ex.message) return ; } //Get info from customer account println(customerAccount.code) println(customerAccount.firstName) println(customerAccount.lastName) //Get info from payment option println(paymentOption.code) println(paymentOption.accessory) println(paymentOption.number) //Get info from payment plan println(paymentPlan.code) println(paymentPlan.firstBillingDate) println(paymentPlan.billingCycleCode) //Get info from revenue transaction println(revenueTransaction.code) println(revenueTransaction.amount) println(revenueTransaction.accountActivityType) //Get info from asset transaction println(transaction.code) println(transaction.amount) println(transaction.accountActivityType) //logout session.logout() } }