public bool PayYourBill(string strCardNumber, string strCCNumber, int strCardExpiryMonth, int strCardExpiryYear , string strAmount, CardTypeV1 CardType, string strFirstName, string strLastname, string strStreet, string strCity, StateV1 State, CountryV1 Country, string ZipCode, string strPhone, string strEmail, string strCustomerIp, out string confirmationId, out string errorMesg) { try { CCAuthRequestV1 ccAuthRequest = new CCAuthRequestV1(); MerchantAccountV1 merchantAccount = new MerchantAccountV1(); merchantAccount.accountNum = WebConfig.AccountNumber; merchantAccount.storeID = WebConfig.StoteId; merchantAccount.storePwd = WebConfig.StotePwd; ccAuthRequest.merchantAccount = merchantAccount; ccAuthRequest.merchantRefNum = WebConfig.ReferancePrefix + DateTime.Now.ToString(); ccAuthRequest.amount = strAmount + ".00"; CardV1 card = new CardV1(); card.cardNum = strCardNumber; CardExpiryV1 cardExpiry = new CardExpiryV1(); cardExpiry.month = strCardExpiryMonth; cardExpiry.year = strCardExpiryYear; card.cardExpiry = cardExpiry; card.cardType = CardType; card.cardTypeSpecified = true; card.cvdIndicator = 1; card.cvdIndicatorSpecified = true; card.cvd = strCCNumber; ccAuthRequest.card = card; BillingDetailsV1 billingDetails = new BillingDetailsV1(); billingDetails.cardPayMethod = CardPayMethodV1.WEB; //WEB = Card Number Provided billingDetails.cardPayMethodSpecified = true; billingDetails.firstName = strFirstName; billingDetails.lastName = strLastname; billingDetails.street = strStreet; billingDetails.city = strCity; //billingDetails.Item = (object)State; // California //billingDetails.country = Country; // United States billingDetails.countrySpecified = false; billingDetails.zip = ZipCode; billingDetails.phone = strPhone; billingDetails.email = strEmail; ccAuthRequest.billingDetails = billingDetails; ccAuthRequest.previousCustomer = true; ccAuthRequest.previousCustomerSpecified = true; ccAuthRequest.customerIP = strCustomerIp; ccAuthRequest.productType = ProductTypeV1.M; //M = Both Digital and Physical(e.g., software downloaded followed by media //shipment) ccAuthRequest.productTypeSpecified = true; //Request a 3D Secure Lookup CardRiskServiceV1[] riskServices = { CardRiskServiceV1.TDS }; ccAuthRequest.cardRiskService = riskServices; // Perform the Web Services call for the purchase CreditCardServiceV1 ccService = new CreditCardServiceV1(); CCTxnResponseV1 ccTxnResponse = ccService.ccPurchase(ccAuthRequest); // Print out the result String responseTxt = ccTxnResponse.code + " - " + ccTxnResponse.decision + " - " + ccTxnResponse.description + Environment.NewLine; // Print out the PAReq and ACSUrl if ((ccTxnResponse.tdsResponse != null) && (ccTxnResponse.tdsResponse.paymentRequest != null) && (ccTxnResponse.tdsResponse.acsURL != null)) { responseTxt += "PaReq: " + ccTxnResponse.tdsResponse.paymentRequest + Environment.NewLine + "ACSUrl: " + ccTxnResponse.tdsResponse.acsURL + Environment.NewLine; } responseTxt += "Details:" + Environment.NewLine; if (ccTxnResponse.detail != null) { for (int i = 0; i < ccTxnResponse.detail.Length; i++) { responseTxt += " - " + ccTxnResponse.detail[i].tag + " - " + ccTxnResponse.detail[i].value + Environment.NewLine; } } responseTxt = responseTxt.Replace("\n", Environment.NewLine); System.Console.WriteLine(responseTxt); if (DecisionV1.ACCEPTED.Equals(ccTxnResponse.decision)) { confirmationId = ccTxnResponse.confirmationNumber; errorMesg = ccTxnResponse.description; return true; // return "Transaction Successful."; } else { confirmationId = string.Empty; errorMesg = ccTxnResponse.description; return false; // return ("Transaction Failed with decision: " + ccTxnResponse.decision); } } catch { throw new ApplicationException("PAYMENT"); confirmationId = string.Empty; errorMesg = "Transaction Failed. Please try again later."; return false; } }
public PaymentGateWay() { BillingDetailsV1 = new BillingDetailsV1(); }