paypal invalid transaction id
I am implementing the Paypal Express Checkout functionality in asp.net
project that requires authorization and then voiding or capturing the
authorized amount. I'm using their API of version=104.0.
As far as I understand the whole process, I am doing everything correctly:
I call SetExpressCheckout method with ActionType set to "Authorize" in
Payment Details
SetExpressCheckoutRequestDetailsType reqDetails = new
SetExpressCheckoutRequestDetailsType();
reqDetails.ReturnURL = "http://some.url";
reqDetails.CancelURL = "http://some.url";
reqDetails.NoShipping = "1";
reqDetails.OrderDescription = "You're about to buy items for " +
payment.Amount.ToString("F");
reqDetails.cpplogoimage = "http://some.ulr/image.jpb";
reqDetails.PaymentDetails = new PaymentDetailsType[1];
reqDetails.PaymentDetails[0] = new PaymentDetailsType();
reqDetails.PaymentDetails[0].PaymentDetailsItem = new
PaymentDetailsItemType[cart.LineItems.Count];
int i = 0;
foreach (LineItemModel li in cart.LineItems)
{
PaymentDetailsItemType item = new PaymentDetailsItemType();
item.Amount = new BasicAmountType();
item.Amount.Value = li.TotalIncludingShipping.ToString("F");
item.Amount.currencyID = CurrencyCodeType.AUD;
item.Name = li.ProductItem.DisplayName;
item.Number = li.ProductItem.SKU;
item.Quantity = li.Quantity.ToString();
item.Description = "";
reqDetails.PaymentDetails[0].PaymentDetailsItem.SetValue(item, i);
i++;
}
reqDetails.OrderTotal = new BasicAmountType()
{
currencyID = CurrencyCodeType.AUD,
Value = payment.Amount.ToString("F")
};
reqDetails.PaymentDetails[0].PaymentAction =
PaymentActionCodeType.Authorization;
reqDetails.PaymentDetails[0].PaymentActionSpecified = true;
SetExpressCheckoutReq req = new SetExpressCheckoutReq()
{
SetExpressCheckoutRequest = new SetExpressCheckoutRequestType()
{
Version = "104.0",
SetExpressCheckoutRequestDetails = reqDetails
}
};
it goes fine and in the back-end of Paypal in the Notification for my test
Personal account I can see the message that the amount of money was
autorized
Then I call DoExpressCheckout. Here is the code of request
DoExpressCheckoutPaymentReq payReq = new DoExpressCheckoutPaymentReq()
{
DoExpressCheckoutPaymentRequest = new
DoExpressCheckoutPaymentRequestType()
{
Version = ConfigurationManager.AppSettings["PaypalAPIVersion"],
DoExpressCheckoutPaymentRequestDetails = new
DoExpressCheckoutPaymentRequestDetailsType()
{
Token = token,
PayerID = payerID,
PaymentDetails = new PaymentDetailsType[1]
}
}
};
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentAction
= PaymentActionCodeType.Authorization;
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentActionSpecified
= true;
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0]
= new PaymentDetailsType();
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].PaymentAction
= PaymentActionCodeType.Authorization;
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].PaymentActionSpecified
= true;
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal
= new BasicAmountType();
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal.currencyID
= CurrencyCodeType.AUD;
payReq.DoExpressCheckoutPaymentRequest.DoExpressCheckoutPaymentRequestDetails.PaymentDetails[0].OrderTotal.Value
= total.ToString("F");
This request returns "Success" too. I save response's
DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID for
future use
But when I run DoAuthorize with the transaction ID from the previous
response, I get "Failure". Here is the request code:
DoAuthorizationReq authReq = new DoAuthorizationReq()
{
DoAuthorizationRequest = new DoAuthorizationRequestType()
{
Version = "104.0",
TransactionID = doCheckoutTransactionId
}
};
authReq.DoAuthorizationRequest.Amount = new BasicAmountType();
authReq.DoAuthorizationRequest.Amount.currencyID = CurrencyCodeType.AUD;
authReq.DoAuthorizationRequest.Amount.Value = total.ToString("F");
The response says "Failure" and Errors array contains 1 item with
ErrorCode=10609 and Message "Invalid Transaction ID"
Do you have any thoughts why this is happening?
Thanks a lot!
No comments:
Post a Comment