2011-02-15 116 views
5

我想知道如果貝寶有一個支付服務,允許用戶在我的網站上輸入他們的信用卡詳細信息(用戶甚至不知道他們是通過貝寶付款)。然後我需要確保它處理重複付款和退款。基本上我需要創建一個實現以下一個PayPal服務:貝寶付款提供商在C#

public interface IPaymentService { 
    Response ValidateCard(NetworkCredential credential, int transactionID, decimal amount, string ipAddress, CardDetails cardDetails, Address billingAddress, Options options); 
    Response RepeatCard(NetworkCredential credential, int oldTransactionID, int newTransactionID, decimal amount); 
    Response RefundCard(NetworkCredential credential, int refundedTransactionID, int newTransactionID, decimal amount); 
} 

public class Address { 
    public virtual string Address1 { get; set; } 
    public virtual string Address2 { get; set; } 
    public virtual string Address3 { get; set; } 
    public virtual string Town { get; set; } 
    public virtual string County { get; set; } 
    public virtual Country Country { get; set; } 
    public virtual string Postcode { get; set; } 
} 

public class CardDetails { 
    public string CardHolderName { get; set; } 
    public CardType CardType { get; set; } 
    public string CardNumber { get; set; } 
    public int ExpiryDateMonth { get; set; } 
    public int ExpiryDateYear { get; set; } 
    public string IssueNumber { get; set; } 
    public string Cv2 { get; set; } 
} 

public class Response { 
    public bool IsValid { get; set; } 
    public string Message { get; set; } 
} 

public class Options { 
    public bool TestStatus { get; set; } 
    public string Currency { get; set; } 
} 

通常這是與其他其他支付提供商如找到付款(SOAP服務)和SagePay相當trivual。

閱讀貝寶文檔讓我頭痛,所以我想我會問這裏。真的很感謝幫助。謝謝

+0

可能重複的[接收付款槽貝寶和信用卡](http://stackoverflow.com/questions/1707701/receiving-payments-trough-paypal-and-credit-card) – 2011-02-15 14:36:49

回答

2

是的,他們這樣做。看看這個文檔。

直接付款API允許您輸入持卡人的信息,然後通過貝寶系統進行處理。

https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside

//process payment 
      Paypal toPayment = new Paypal(); 
      toPayment.BillingAddress = new Address(txt_BillingAddr1.Text, txt_BillingAddr2.Text, txt_BillingCity.Text, ddl_BillingState.SelectedValue, txt_BillingZip.Text, ""); 
      toPayment.BillingCountry = com.paypal.soap.api.CountryCodeType.US; 
      toPayment.BillingFName = txt_BillingFName.Text; 
      toPayment.BillingLName = txt_BillingLName.Text; 
      toPayment.BillingMName = txt_BillingMName.Text; 
      toPayment.BillingPhoneNumber = txt_BillingPhone.Text; 
      toPayment.BillingSuffix = txt_BillingSuffix.Text; 
      toPayment.ContactPhoneNumber = txtPhone.Text; 
      toPayment.CreditCardExpireMonth = Convert.ToInt32(ddl_CCExpireMonth.SelectedIndex + 1); 
      toPayment.CreditCardExpireYear = Convert.ToInt32(ddl_CCExpireYear.SelectedValue); 
      toPayment.CreditCardNumber = txt_CreditCard.Text; 
      toPayment.CreditCardSecurityCode = txt_CCID.Text; 
      switch (lst_CCTypes.SelectedValue) 
      { 
       case "Visa": 
        toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Visa; 
        break; 
       case "MasterCard": 
        toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.MasterCard; 
        break; 
       case "AmericanExpress": 
        toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Amex; 
        break; 
       case "Discover": 
        toPayment.CreditCardType = com.paypal.soap.api.CreditCardTypeType.Discover; 
        break; 
      } 
      toPayment.UserHostAddress = Request.UserHostAddress; 
      toPayment.OrderTotal = StaticMethods.getDecimal(lbl_TotalPrice_cout.Text, 0); 

      //set API Profile 
      toPayment.APIProfile = Master.PayPal_API_Profile; 

      DoDirectPaymentResponseType toResponse = new DoDirectPaymentResponseType(); 
      toResponse = toPayment.processDirectPaymentTransaction(); 

這裏是多一點點的你...這是一個實際的生產現場,我對工作的實際代碼通過PayPal支付需要

toResponse包含確認屬性....所以你可以做類似

switch(toResponse.Ack) 
{ 
case AckCodeType.Failure; 
    // The card is bad. void transaction. 
    lblResponse = toResponse.Errors[0].LongMessage; 
    Break; 
case AckCodeType.Success 
    // The card is good. Go forward with process 
} 
0

是的,PayPal在Website Payments Pro下提供此服務。你可以閱讀更多關於它here

enter image description here

第一流量是直接支付和第二是快速結賬。客戶在直接付款下的網站上輸入卡詳情。