简体   繁体   English

DirectPayment方法贝宝问题

[英]DirectPayment method Paypal problem

I am trying to implement Direct payment method as I have user's credit card information etc in my database. 我正在尝试实现直接付款方式,因为我的数据库中有用户的信用卡信息等。 This is the sample that I am referring: 这是我要引用的示例:

using System;
using System.Collections.Generic;
using System.Text;
using com.paypal.sdk.services;
using com.paypal.sdk.profiles;
using com.paypal.sdk.util;
using com.paypal.soap.api;

namespace ASPDotNetSamples
{
    public class DoDirectPayment
    {
        public DoDirectPayment()
        {
        }
        public string DoDirectPaymentCode(string paymentAction, string amount, string creditCardType, string creditCardNumber, string expdate_month, string cvv2Number, string firstName, string lastName, string address1, string city, string state, string zip, string countryCode, string currencyCode)
        {

            com.paypal.soap.api.DoDirectPaymentReq req = new com.paypal.soap.api.DoDirectPaymentReq();


            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "sdk-three_api1.sdk.com";
            profile.APIPassword = "QFZCWN5HZM8VBG7Q";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment = "sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] = "51.0";
            encoder["METHOD"] = "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"] = paymentAction;
            encoder["AMT"] = amount;
            encoder["CREDITCARDTYPE"] = creditCardType;
            encoder["ACCT"] = creditCardNumber;
            encoder["EXPDATE"] = expdate_month;
            encoder["CVV2"] = cvv2Number;
            encoder["FIRSTNAME"] = firstName;
            encoder["LASTNAME"] = lastName;
            encoder["STREET"] = address1;
            encoder["CITY"] = city;
            encoder["STATE"] = state;
            encoder["ZIP"] = zip;
            encoder["COUNTRYCODE"] = countryCode;
            encoder["CURRENCYCODE"] = currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];

        }
    }
}

This is the link: 这是链接:

https://cms.paypal.com/cms_content/US/en_US/files/developer/nvp_DoDirectPayment_cs.txt https://cms.paypal.com/cms_content/US/zh_CN/files/developer/nvp_DoDirectPayment_cs.txt

However, I am getting error 'NVPCallerServices' cannot be found. 但是,我收到错误消息“ NVPCallerServices”。 I already have reference to paypal_base. 我已经参考了paypal_base。 Can anybody tell me what is the issue? 谁能告诉我这是什么问题?

Yeah, thats the Pay Pal API :) 是的,那就是Pay Pal API :)

The sample is likely a bit outdated. 该示例可能有点过时了。 The NVPCallerServices class seems to be named CallerServices now. NVPCallerServices类现在似乎已命名为CallerServices

So try to replace the line 所以尝试更换线

NVPCallerServices caller = new NVPCallerServices();

with

CallerServices caller = new CallerServices();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM