简体   繁体   中英

CyberSource Simple Order API Capture PayPal transaction

I'm attempting to capture a PayPal transaction that has been authorized using the PayPal button. I'm trying to use CyberSource Simple Order API to do this. I have the only 3 pieces of information that seem to come back from the PayPal button are: payerID , paymentID and paymentToken . I've tried a few ways of handing this off to the Simple Order API, but always get a 102 code with the DECLINE message in the response. Cybersource's logging system indicates this is because The following request field(s) is either invalid or missing: request_token .

Do I need to conduct the whole transaction - authorize and capture - via cybersource? Or what is the way I can take the paypal-generated button and authorize a transaction, then capture it via CyberSource?

Here's my code snippet for the CyberSource SOAPI request:

RequestMessage request = new RequestMessage
{
    merchantID = WebConfigurationManager.AppSettings["cybs.merchantID"]
    , payPalDoCaptureService = new PayPalDoCaptureService {
            run = "true"
            , invoiceNumber = orders
            , paypalAuthorizationId = authId
            , paypalAuthorizationRequestToken = requestToken
            , completeType = "Complete" }
    , clientApplication = "MyClient Application"
    , clientApplicationVersion = "2.0"
    , clientApplicationUser = userName
    , clientEnvironment = WebConfigurationManager.AppSettings["Tier"]
    , merchantReferenceCode = orders
    , customerID = OrderConstants.CustomerNumber
    , merchantDefinedData = new MerchantDefinedData { field1 = "Customer #: " + OrderConstants.CustomerNumber, field2 = orders }
    , purchaseTotals = new PurchaseTotals { currency = "usd", grandTotalAmount = total, taxAmount = taxtotal }
    , item = items.ToArray()
};

ReplyMessage reply = new ReplyMessage();
try
{
    reply = SoapClient.RunTransaction(request);
}
catch (Exception ex)
{
    reply.decision = "SYSTEM ERROR";
    reply.additionalData = string.Format("Error processing request. Exception message: {0}", ex.Message);
}

Have you tried setting up your request like this? Pay no attention to the values I used, but I am looking at the example in the docs (Example 21 Request for payPalDoCaptureService). You'll need to ctrl+f to find it.

RequestMessage request = new RequestMessage
{
    payPalDoCaptureService_run=true
    , merchantID = WebConfigurationManager.AppSettings["cybs.merchantID"]
    , merchantReferenceCode = HTNsubscription9647
    , purchaseTotals = new PurchaseTotals { currency = "usd", grandTotalAmount = total, taxAmount = taxtotal }
    , payPalDoCaptureService = new PayPalDoCaptureService 
      {
         run = "true"
        , invoiceNumber = orders
        , paypalAuthorizationId = authId
        , paypalAuthorizationRequestID = authReqId
        , paypalAuthorizationRequestToken = requestToken
        , completeType = "Complete" 
      }
}

I did end up solving this problem. My question involving whether I needed to employ CyberSource from end-to-end was the correct path. Eventually I figured out - after talking for days with CyberSource support - that I needed to use their "Set Service" in a WebApi method to generate the PayPal "token" and give that to the PayPal button via ajax within the javascript that generates the button. I also had to dig deep into their and PayPal's documentation and to figure out how to make that work because it wasn't super clear initially. At any rate, once I did the Set service, I gathered the information in the response from CyberSource, along with the PayPal token, and send that along to a Get Details service call (also CyberSource). Finally that information is given to a combined Do Sale and Do Capture service call and the funds are captured. The button only allowed a user to log into their PayPal account and verify they wanted to continue with the transaction.

CyberSource's documentation is a little lacking in clarity with regards to this, and they link to a deprecated set of PayPal documentation, which doesn't make anything easier.

As the error says you have git invalid data, please check the reply fields invalidField_0 through invalidField_N for the invalid fields.

I hope these Requesting the Authorization Service samples will help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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