From 9880b22705ff3ae26c1a0f9a3a29bf132cb32e77 Mon Sep 17 00:00:00 2001 From: Darragh O'Keeffe Date: Fri, 21 Jun 2019 11:55:40 +0100 Subject: [PATCH 1/4] Billing Typo in RealexConnector.ts --- src/Gateways/RealexConnector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gateways/RealexConnector.ts b/src/Gateways/RealexConnector.ts index 98f07feb..57fdba5d 100644 --- a/src/Gateways/RealexConnector.ts +++ b/src/Gateways/RealexConnector.ts @@ -293,7 +293,7 @@ export class RealexConnector extends XmlGateway implements IRecurringService { request.SHIPPING_CODE = encoder(builder.shippingAddress.postalCode || ""); request.SHIPPING_CO = encoder(builder.shippingAddress.country || ""); } - if (builder.sillingAddress) { + if (builder.billingAddress) { request.BILLING_CODE = encoder(builder.billingAddress.postalCode || ""); request.BILLING_CO = encoder(builder.billingAddress.country || ""); } From cf5cb4635b31d7fcfddae129fb9839e4b5ddbe0c Mon Sep 17 00:00:00 2001 From: Francis Levasseur Date: Mon, 16 Sep 2019 15:31:55 -0400 Subject: [PATCH 2/4] handle html error page --- src/Gateways/RealexConnector.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Gateways/RealexConnector.ts b/src/Gateways/RealexConnector.ts index 57fdba5d..9c768042 100644 --- a/src/Gateways/RealexConnector.ts +++ b/src/Gateways/RealexConnector.ts @@ -614,7 +614,9 @@ export class RealexConnector extends XmlGateway implements IRecurringService { const result = new Transaction(); const root = xml(rawResponse); - this.checkResponse(root); + var r=this.checkResponse(rawResponse,root); + result.responseCode = r.code; + result.responseMessage = r.message; result.responseCode = root.findtext(".//result"); result.responseMessage = root.findtext(".//message"); @@ -636,17 +638,23 @@ export class RealexConnector extends XmlGateway implements IRecurringService { ) { const root = xml(rawResponse); - this.checkResponse(root); + this.checkResponse(rawResponse,root); return builder.entity as T; } - protected checkResponse(root: Element, acceptedCodes?: string[]) { + protected checkResponse(rawResponse: string,root: Element, acceptedCodes?: string[]) { if (!acceptedCodes) { acceptedCodes = ["00"]; } - const responseCode = root.findtext(".//result"); - const responseMessage = root.findtext(".//message"); + var responseCode = root.findtext(".//result"); + var responseMessage = root.findtext(".//message"); + if(!responseCode){ + var _rc=rawResponse.match('error_code">([0-9]+)([0-9a-zA-Z\-\._\ ]+) Date: Tue, 17 Sep 2019 09:55:24 -0400 Subject: [PATCH 3/4] added shipping and billing code to process avs with realex --- src/Gateways/RealexConnector.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Gateways/RealexConnector.ts b/src/Gateways/RealexConnector.ts index 9c768042..95fa5a89 100644 --- a/src/Gateways/RealexConnector.ts +++ b/src/Gateways/RealexConnector.ts @@ -431,6 +431,22 @@ export class RealexConnector extends XmlGateway implements IRecurringService { cData(builder.reasonCode.toString()), ); } + if (builder.shippingAddress) { + subElement(request, "shipping_code").append( + cData(builder.shippingAddress.shipping_code || builder.shippingAddress.postalCode || "") + ); + subElement(request, "shipping_co").append( + cData(builder.shippingAddress.country || "") + ); + } + if (builder.billingAddress) { + subElement(request, "billing_code").append( + cData(builder.billingAddress.billing_code || builder.billingAddress.postalCode || "") + ); + subElement(request, "billing_co").append( + cData(builder.billingAddress.country || "") + ); + } if (builder.description) { const comments = subElement(request, "comments"); From 223496c031444b5f8ec4380b08ce9248b1ab6889 Mon Sep 17 00:00:00 2001 From: Francis Levasseur Date: Wed, 25 Sep 2019 14:34:23 -0400 Subject: [PATCH 4/4] fixed number format unwanted decimals issue with toFixed --- src/Gateways/RealexConnector.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gateways/RealexConnector.ts b/src/Gateways/RealexConnector.ts index 95fa5a89..63809ec2 100644 --- a/src/Gateways/RealexConnector.ts +++ b/src/Gateways/RealexConnector.ts @@ -795,9 +795,13 @@ export class RealexConnector extends XmlGateway implements IRecurringService { throw new UnsupportedTransactionError(); } } - protected numberFormat(amount: number | string) { +<<<<<<< Updated upstream const f = parseFloat(amount.toString()); return (parseFloat(f.toFixed(2)) * 100).toString(); +======= + const f = parseFloat(amount.toString()) * 100; + return parseInt(f.toString()).toString(); +>>>>>>> Stashed changes } }