Search code examples
paypalpaypal-sandbox

We’re sorry, we can’t complete your payment now. Please try again later - PayPal Payments Pro


I've implemented IFrame version of Website Payments Pro Hosted. I register my button using the button API, get back a Url to feed into an IFrame which shows me the PayPal pay by credit card or login and pay options.

My integration is working when signing in and using my PayPal account but when I enter credit card details, I get the error:

We’re sorry, we can’t complete your payment now. Please try again later.

I don't get any other information that this and my notification Url isn't touched with an error code or anything.

This is the code I'm using to get the Url to feed into the IFrame (Note: I've added the billing address fields on the assumption it could be throwing an error as I need address details to pay by card.

public PayPalPaymentProRegistrationResponse RegisterTransaction(PayPalPaymentProRequest request)
{
    CountryCodeType countryCodeType;
    if (!Enum.TryParse(request.Order.BillingContact.Address.Country.Iso2Code, true, out countryCodeType))
        return new PayPalPaymentProRegistrationResponse(PayPalPaymentProRegistrationResponseType.Error, "Billing country not supported.");

    var service = new PayPalAPIInterfaceServiceService(GetConfig(request));
    var createButtonResponse = service.BMCreateButton(new BMCreateButtonReq
    {
        BMCreateButtonRequest = new BMCreateButtonRequestType
        {
            ButtonType = ButtonTypeType.PAYMENT,
            ButtonCode = ButtonCodeType.TOKEN,
            ButtonCountry = countryCodeType,
            ButtonVar = new List<string>
            {
                String.Format("subtotal={0}", _salesOrderPriceService.GetGrossTotal(request.Order)),
                String.Format("notify_url={0}", request.NotifyUrl),
                String.Format("return={0}", request.ReturnUrl),
                String.Format("invoice={0}", request.Order.Id),
                String.Format("currency_code={0}", request.Order.Currency.Code),
                String.Format("cancel_return={0}", request.CancelReturnUrl),
                "billing_first_name=my",
                "billing_last_name=name",
                "billing_address1=address 1",
                "billing_city=town",
                "billing_state=county",
                "billing_zip=PO CODE",
                "billing_country=GB",
                "showHostedThankyouPage=true",
                "template=templateD"
            }
        }
    });

    return new PayPalPaymentProRegistrationResponse
    {
        ForwardingUrl = createButtonResponse.Email,
        Status = PayPalPaymentProRegistrationResponseType.Ok
    };
}

Note: I am using credit card number 4111111111111111. If I try with some other number 4929000000006 it will return a different error saying the information isn't valid and highlight the credit card number field so I'm confident the test number I'm using is Ok.

I am integrating using my Sandbox account.

Does anyone have any points on what could be going wrong?


Solution

  • It turns out the credit card number I was using for SandBox was wrong. You need to log into your Sandbox account and look at the profile. Within that, you will see a credit card number you are allowed to test with.

    I also added "paymentaction=sale" to my button request.

    With both of these done, it now takes payment.