public string Purchase(string paymentUrl, CreditCardInfo creditCard) { var postData = String.Format("cardNumber={0}&" + "cvNumber={1}&" + "expMonth={2}&" + "expYear={3}&" + "cardFirstName={4}&" + "cardLastName={5}&" + "cardAddress={6}&" + "cardCity={7}&" + "cardState={8}&" + "cardPostal={9}&" + "cardCountry={10}&" + "contactName={11}&" + "contactPhone={12}&" + "contactEmail={13}&" + "cryptedStepCheck={14}&finishForm=Purchase", creditCard.CardNumber, creditCard.VerificationNumber, creditCard.ExpirationMonth, creditCard.ExpirationYear, HttpUtility.UrlEncode(creditCard.FirstName), HttpUtility.UrlEncode(creditCard.LastName), HttpUtility.UrlEncode(creditCard.Address), HttpUtility.UrlEncode(creditCard.City), creditCard.State, creditCard.Postal, "US", HttpUtility.UrlEncode(creditCard.ContactName), creditCard.ContactPhone, HttpUtility.UrlEncode(creditCard.ContactEmail), string.Empty); return(ExecutePost(paymentUrl, postData, "secure.craigslist.org")); }
public ConfirmationPayment PostingAdsOnCraigslist(string email, string password, VehicleInfo vehicle, CreditCardInfo creditCard) { //Step 2: log on if (StatusCode == 0) { WebRequestPost(email, password); if (StatusCode != 302) { return(new ConfirmationPayment { Status = CraigslistPostingStatus.Error, ErrorMessage = "You forgot to input Username/Password in Admin setting? or Your account is invalid." }); } } if (string.IsNullOrEmpty(vehicle.CraigslistCityUrl)) { return(new ConfirmationPayment { Status = CraigslistPostingStatus.Error, ErrorMessage = "You forgot to set State/City/Location in Admin setting. Let's do that first." }); } var locationPostUrl = GetLocationPostUrl(vehicle.CraigslistCityUrl); var locationUrl = GetEncodedLocationUrl(locationPostUrl); var typePostingUrl = GetTypePostingUrl(locationUrl); var cryptedStepCheck = GetCryptedStepCheckFromUrl(typePostingUrl); //Step 3: get category & Crypted code var categoryChoosingUrl = GetCategoryChoosingUrl(locationUrl, cryptedStepCheck); cryptedStepCheck = GetCryptedStepCheckFromUrl(categoryChoosingUrl); //Step 4: get sub location & Crypted code var subLocationChoosingUrl = GetSubLocationChoosingUrl(locationUrl, cryptedStepCheck); cryptedStepCheck = GetCryptedStepCheckFromUrl(subLocationChoosingUrl); //Step 4: go to create posting & get Crypted code if (vehicle.CityIndex > 0) { var createPostingUrl = GetCreatePostingUrl(vehicle.CityIndex, locationUrl, cryptedStepCheck); cryptedStepCheck = GetCryptedStepCheckFromUrl(createPostingUrl); } //Step 5: posting var imageEditingUrl = Posting(vehicle, locationUrl, cryptedStepCheck); cryptedStepCheck = GetCryptedStepCheckFromUrl(imageEditingUrl); //Step 6: upload images UploadImages(locationUrl, cryptedStepCheck, vehicle); cryptedStepCheck = GetCryptedStepCheckFromUrl(imageEditingUrl); //Step 7: preview var previewUrl = GetPreviewUrl(locationUrl, cryptedStepCheck); cryptedStepCheck = GetCryptedStepCheckFromUrl(previewUrl); //Step 8: go to billing page & get Crypted code var billingUrl = GetBillingUrl(locationUrl, cryptedStepCheck, 1); cryptedStepCheck = GetCryptedStepCheckFromUrl(billingUrl); GetBillingUrl(locationUrl, cryptedStepCheck, 2); if (billingUrl.Contains("mailoop")) { return(new ConfirmationPayment() { Status = CraigslistPostingStatus.EmailVerification, ErrorMessage = "This is your first post on this device so you should receive an email shortly, with a link to confirm your ad. Please check Inbox or Spam " + email }); } //Step 9: payment var paymentUrl = GetPaymentUrl(billingUrl); if (String.IsNullOrEmpty(paymentUrl)) { return(new ConfirmationPayment() { Status = CraigslistPostingStatus.PaymentError, ErrorMessage = "PaymentError: please look at billing URL for more detail " + billingUrl }); } creditCard.CryptedStepCheck = cryptedStepCheck; var confirmationPaymentUrl = paymentUrl; try { confirmationPaymentUrl = Purchase(paymentUrl, creditCard); if (String.IsNullOrEmpty(confirmationPaymentUrl)) { return(new ConfirmationPayment() { Status = CraigslistPostingStatus.PaymentError, ErrorMessage = "PaymentError: Cannot purchase " + confirmationPaymentUrl }); } return(GetConfirmationPaymentInfo(confirmationPaymentUrl)); } catch (Exception) { return(new ConfirmationPayment() { Status = CraigslistPostingStatus.PaymentError, ErrorMessage = "PaymentError: Cannot purchase (Exception) " + confirmationPaymentUrl }); } }