【问题标题】:DirectPayment method Paypal problemDirectPayment方式Paypal问题
【发布时间】:2011-11-21 00:51:54
【问题描述】:

我正在尝试实施直接付款方式,因为我的数据库中有用户的信用卡信息等。这是我指的示例:

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"];

        }
    }
}

这是链接:

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

但是,我收到错误“找不到 NVPCallerServices”。我已经参考了 paypal_base。谁能告诉我是什么问题?

【问题讨论】:

    标签: c# paypal


    【解决方案1】:

    是的,这就是 Pay Pal API :)

    样本可能有点过时了。 NVPCallerServices 类现在似乎被命名为 CallerServices

    所以尝试换行

    NVPCallerServices caller = new NVPCallerServices();
    

    CallerServices caller = new CallerServices();
    

    【讨论】:

    • 我没想到会发生这种情况,因为我指的是最新的文档 - 他们网站上的那个。贝宝是可怕的。不知道为什么客户喜欢这样。
    • 感觉 pay pal 有无数版本的 sdks api 文档网站和遍布网络的支付产品……真恶心:)
    • Paypal 文档太烂了——如果没有这个答案,我不知道我怎么会弄明白。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-01
    • 1970-01-01
    • 2012-07-28
    • 2016-08-19
    • 2011-10-28
    • 1970-01-01
    相关资源
    最近更新 更多