CyberSource / cybersource-rest-client-dotnetstandard

.NET Standard client library for the CyberSource REST API
7 stars 20 forks source link

Breaking change in Dotnet standard release v0.0.1.32? #83

Closed AdTarling closed 3 months ago

AdTarling commented 5 months ago

I've just upgraded our CyberSource.Rest.Client.NetStandard library reference from v0.0.1.31 to v0.0.1.32 and I'm seeing a breaking change when calling PaymentsApi.CreatePaymentAsync()

Initially the server was responding with: "MISSING_FIELD\",\"message\":\"Declined - The request is missing one or more fields\",\"details\":[{\"field\":\"orderInformation.lineItems[0]\"

As such, to the Ptsv2paymentsOrderInformation object I added: LineItems: new List { new() }

The server now responds with: "SERVER_ERROR\",\"reason\":\"SYSTEM_ERROR\",\"message\":\"Request failed due to unknown system error.\"

It's perfectly legitimate that clients of the API would want to submit payment without creating order lines, but at a minimum the API shouldn't be breaking if an empty order line is submitted to circumvent that requirement.

Release v0.0.1.31 is fine without the additional LineItems initialisation.

AdTarling commented 3 months ago

Can I get some feedback on this please. Something has obviously changed in the API as I'm still getting the same errors as above with code that is working fine against v0.0.1.31. As such, there's some sort of breaking change after that release. @monu-kumar-visa

monu-kumar-visa commented 3 months ago

Hi @AdTarling ,

We are happy to look into this.

Can you provide a sample request, similar to what you are sending, so that we can reproduce the error?

Also, would it be possible for you to try our latest version and see whether that works?

-- @monu-kumar-visa

AdTarling commented 3 months ago

Thanks @monu-kumar-visa, much appreciated. The latest version doesn't work I'm afraid. The csharp object for the request is as follows, to the PaymentsApi.CreatePaymentAsync method (this is test data fyi). I don't have the raw request going to the API as that's obviously buried inside the Cybersource library, but hopefully should help diagnose. This was working up to and including v0.0.1.31

{class CreatePaymentRequest { ClientReferenceInformation: class Ptsv2paymentsClientReferenceInformation { Code: 740794 ReconciliationId: PausedRequestId: TransactionId: Comments: Partner: ApplicationName: ApplicationVersion: ApplicationUser: }

ProcessingInformation: class Ptsv2paymentsProcessingInformation { ActionList: System.Collections.Generic.List`1[System.String] EnableEscrowOption: ActionTokenTypes: BinSource: Capture: True ProcessorId: BusinessApplicationId: CommerceIndicator: CommerceIndicatorLabel: PaymentSolution: ReconciliationId: LinkId: PurchaseLevel: TransactionTimeout: IntentsId: PaymentId: ReportGroup: VisaCheckoutId: IndustryDataType: AuthorizationOptions: CaptureOptions: RecurringOptions: BankTransferOptions: PurchaseOptions: ElectronicBenefitsTransfer: LoanOptions: WalletType: NationalNetDomesticData: JapanPaymentOptions: MobileRemotePaymentType: ExtendedCreditTotalCount: NetworkRoutingOrder: PayByPointsIndicator: Timeout: IsReturnAuthRecordEnabled: NetworkPartnerId: PaymentType: }

IssuerInformation: PaymentInformation: class Ptsv2paymentsPaymentInformation { Card: TokenizedCard: DirectDebit: FluidData: Customer: class Ptsv2paymentsPaymentInformationCustomer { CustomerId: Id: 142CB96FBCC884D3E063AF598E0A1483 }

PaymentInstrument: class Ptsv2paymentsPaymentInformationPaymentInstrument { Id: 1A119CD507A913EFE063AF598E0A510D }

InstrumentIdentifier: ShippingAddress: LegacyToken: Bank: Options: PaymentType: InitiationChannel: Sepa: EWallet: }

OrderInformation: class Ptsv2paymentsOrderInformation { AmountDetails: class Ptsv2paymentsOrderInformationAmountDetails { GiftWrapAmount: 367.43 TotalAmount: SubTotalAmount: Currency: GBP DiscountAmount: DutyAmount: GratuityAmount: TaxAmount: NationalTaxIncluded: TaxAppliedAfterDiscount: TaxAppliedLevel: TaxTypeCode: FreightAmount: ForeignAmount: ForeignCurrency: ExchangeRate: ExchangeRateTimeStamp: Surcharge: SettlementAmount: SettlementCurrency: AmexAdditionalAmounts: TaxDetails: ServiceFeeAmount: OriginalAmount: OriginalCurrency: CashbackAmount: CurrencyConversion: Order: }

BillTo: ShipTo: LineItems: InvoiceDetails: ShippingDetails: ReturnsAccepted: IsCryptocurrencyPurchase: CutoffDateTime: PreOrder: PreOrderDate: Reordered: TotalOffersCount: }

BuyerInformation: RecipientInformation: DeviceInformation: MerchantInformation: AggregatorInformation: ConsumerAuthenticationInformation: class Ptsv2paymentsConsumerAuthenticationInformation { Cavv: TransactionFlowIndicator: CavvAlgorithm: EciRaw: ParesStatus: VeresEnrolled: Xid: UcafCollectionIndicator: UcafAuthenticationData: StrongAuthentication: DirectoryServerTransactionId: PaSpecificationVersion: AuthenticationType: ResponseAccessToken: AcsTransactionId: AcsWindowSize: AlternateAuthenticationData: AlternateAuthenticationDate: AlternateAuthenticationMethod: AuthenticationDate: AuthenticationTransactionId: ChallengeCancelCode: ChallengeCode: ChallengeStatus: CustomerCardAlias: DecoupledAuthenticationIndicator: DecoupledAuthenticationMaxTime: DefaultCard: DeviceChannel: InstallmentTotalCount: MerchantFraudRate: MarketingOptIn: MarketingSource: Mcc: MerchantScore: MessageCategory: NetworkScore: NpaCode: OverridePaymentMethod: OverrideCountryCode: PriorAuthenticationData: PriorAuthenticationMethod: PriorAuthenticationReferenceId: PriorAuthenticationTime: ProductCode: ReturnUrl: https://local.staustellfamilygrouprebuild.co.uk/wholesale/basket/payment/step-up/ RequestorId: RequestorInitiatedAuthenticationIndicator: RequestorName: ReferenceId: 615e71df-eda9-4754-b7e8-b7a1cf36a969 SdkMaxTimeout: SecureCorporatePaymentIndicator: TransactionMode: WhiteListStatus: EffectiveAuthenticationType: SignedParesStatusReason: SignedPares: }

PointOfSaleInformation: MerchantDefinedInformation: MerchantDefinedSecureInformation: InstallmentInformation: TravelInformation: HealthCareInformation: PromotionInformation: TokenInformation: InvoiceDetails: ProcessorInformation: AgreementInformation: RiskInformation: AcquirerInformation: RecurringPaymentInformation: HostedPaymentInformation: WatchlistScreeningInformation: } }

AdTarling commented 3 months ago

The error returned is then {"Error calling CreatePayment: {\"id\":\"7175867623346693604951\",\"submitTimeUtc\":\"2024-06-05T11:26:02Z\",\"status\":\"INVALID_REQUEST\",\"reason\":\"MISSING_FIELD\",\"message\":\"Declined - The request is missing one or more fields\",\"details\":[{\"field\":\"orderInformation.lineItems[0]\",\"reason\":\"MISSING_FIELD\"}]}"}

Suggesting that the orderinformation line item collection has now become mandatory.....

monu-kumar-visa commented 3 months ago

Hi @AdTarling ,

In the example you gave, totalAmount is not in orderInformation. Because totalAmount is missing, the API is looking for lineItems to order to calculate totalAmount to approve or capture.

Could you please help us to understand why the totalAmount is not present in orderInformation?

AdTarling commented 3 months ago

Thanks @monu-kumar-visa

Much appreciated, I know what's happened. We were initialising the orderInformation object without overtly specifying the totalAmount in the constructor image

That was fine whilst totalAmount was the first property in the stack. However, the v0.0.1.32 release added giftWrapAmount with the same type into position 1, meaning that when our code referenced that version (or above) it was initialising the giftWrapAmount and not the totalAmount.

As such, I've updated our code to now overtly set the totalAmount and all is working again image

So that's all now fixed and thanks for the extra info. Just a note to say that it would be of help if the API returned specific errors for mandatory properties, or the csharp objects made them not null if they have the ability to completely break the call and return just that catchall message.

Thanks again, Adam.

monu-kumar-visa commented 3 months ago

Hi @AdTarling,

We will share your message with the API team.