Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CyberSource Simple Order API Capture PayPal transaction

Tags:

c#

asp.net

paypal

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);
}
like image 937
Matt Avatar asked Aug 17 '17 16:08

Matt


People also ask

What is capture order PayPal?

The intent to either capture payment immediately or authorize a payment for an order after order creation. The possible values are: CAPTURE . The merchant intends to capture payment immediately after the customer makes a payment.

What is cybersource simple order API?

Cybersource APIs provide access to every service Cybersource offers. With Simple Order API, Cybersource provides the client software. It's the right choice for merchants who want scalability, a full range of services, and greater control of the buying experience.


2 Answers

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" 
      }
}
like image 198
DoloMike Avatar answered Oct 28 '22 11:10

DoloMike


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.

like image 27
Matt Avatar answered Oct 28 '22 09:10

Matt