Paypal支払いを.NET 4.0 C#WinFormアプリケーションに統合しようとしていますが、paypalサイトでブラウザを開くことなくDirectPaymentを実行しています。 WebMethod属性C#のWinForm Paypalとasmx Webサービスとの統合
public DoDirectPaymentResponseType DoDirectPaymentAPIOperation(string
amountinUSDollar, string creditCardType, string creditCardNumber, int
exp_month, int exp_year, string firstName, string middleName, string
lastName, string address1, string address2, string city, string state,
string zip, string phoneNumber, string CVV2)
{
DoDirectPaymentResponseType response = new
DoDirectPaymentResponseType();
DoDirectPaymentReq wrapper = new DoDirectPaymentReq();
DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
DoDirectPaymentRequestDetailsType requestDetails = new
DoDirectPaymentRequestDetailsType();
requestDetails.PaymentAction = (PaymentActionCodeType)
Enum.Parse(typeof(PaymentActionCodeType), "SALE");
CreditCardDetailsType creditCard = new CreditCardDetailsType();
PayerInfoType cardOwner = new PayerInfoType();
PersonNameType payer = new PersonNameType();
payer.FirstName = firstName;
payer.MiddleName = middleName;
payer.LastName = lastName;
cardOwner.PayerName = payer;
creditCard.CardOwner = cardOwner;
creditCard.CreditCardNumber = creditCardNumber;
if (creditCardType == "VISA")
{
creditCard.CreditCardType = CreditCardTypeType.VISA;
}
else if (creditCardType == "MasterCard")
{
creditCard.CreditCardType = CreditCardTypeType.MASTERCARD;
}
creditCard.CVV2 = CVV2;
creditCard.ExpMonth = exp_month;
creditCard.ExpYear = exp_year;
requestDetails.PaymentDetails = new PaymentDetailsType();
requestDetails.PaymentDetails.NotifyURL = "http://IPNhost";
BasicAmountType paymentAmount = new
BasicAmountType(CurrencyCodeType.USD, amountinUSDollar);
requestDetails.PaymentDetails.OrderTotal = paymentAmount;
wrapper.DoDirectPaymentRequest = request;
Dictionary<string, string> config = getConfigDict();
PayPalAPIInterfaceServiceService service = new
PayPalAPIInterfaceServiceService(config);
response = service.DoDirectPayment(wrapper);
}
それは私はこのエラーを取得するコードの最後の行には、APIの呼び出しをしよう: 「例外のHttpConnectionで実行します。無効なHTTP応答要求が中止されましたが:SSLを作成できませんでした。/TLSセキュアチャネル "} System.Exception {PayPal.Exception.PayPalException}。
私はPayPalでの.NET 4.5 WebフォームのWebアプリケーションを持っていたが、私はそのGlobal.asaxファイルでこの
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
を定義するために持っていたし、それはその特定のアプリケーションのための問題を解決し、私は私を発見しているに統合しました.NET 4.0のために、この
ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072;
を使用する必要がありますが、私の質問は:
これは私が私のコードでは、この行を置くべき5月の問題に対する解決策、でしょうか?私のasmx webserviceにはGlobal.asaxが存在しないためです。
私は推測していますが、「NotifyURL」にHTTPSが有効になっていないようです。例外はPayPal側から生成されたようですが、呼び出しがあったことは確かではありません。代わりに、接続を開始しているURLにSSL/TLSが有効になっていない – DiskJunky
@DiskJunky、おかげで、私の問題が解決しました。私は "response = service.DoDirectPayment(wrapper)"の直前にこの行を書きました。 NotifyURLにhttpsを定義していますが、これ以上エラーは発生しません。今、私は失敗応答を得ているので、別の質問を定式化しようとしており、必要なすべてのパラメータをAPIに渡しています – Eagle