Skip to content

Surcharge XML is too long #23

@Patabugen

Description

@Patabugen

This isn't a bug in the library so much as an annoyance in SagePay, but you may have some insight which helps.

When sending SurchargeXML there is a maximum length of the XML otherwise SagePay returns:

INVALID : 3175 : The Surcharge XML is too long.

I've not calculated exactly what the limit is (though it's around 800 characters) but there is enough space to set all but about three card types

$surcharge->addPercentage('VISA', $surchargeAmount)
    ->addPercentage('AMEX', $surchargeAmount)
    ->addPercentage('DELTA', $surchargeAmount)
    ->addPercentage('JCB', $surchargeAmount)
    ->addPercentage('DC', $surchargeAmount)
    ->addPercentage('MC', $surchargeAmount)
    ->addPercentage('UKE', $surchargeAmount)
    ->addPercentage('MAESTRO', $surchargeAmount)
//  ->addPercentage('MCDEB', $surchargeAmount)
//  ->addPercentage('IT', $surchargeAmount)
//  ->addPercentage('GIROPAY', $surchargeAmount)
    ->addPercentage('SOFORT', $surchargeAmount);

Additionally using a Fixed amount lets you specify all card types because "fixed" is a shorter word than "percentage".

It'd be good to create a validator to catch this.
If this is indeed an issue with SagePay I'd suggest workarounds are either:

  1. Use Fixed amounts always, and calculate the percentage if need be
  2. Recognise a few card types you're not going to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions