Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connectors): [Tesouro] Integrate no-threeds cards (#9632)

AkshayaFoigerfbd92fa19474
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 32c47be831..c9e8b57477 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -12143,6 +12143,7 @@
"stripebilling",
"taxjar",
"threedsecureio",
+ "tesouro",
"tokenex",
"tokenio",
"trustpay",
@@ -30485,6 +30486,7 @@
"stax",
"stripe",
"stripebilling",
+ "tesouro",
"trustpay",
"trustpayments",
"tokenio",
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 3667161425..27e70e9ee9 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -8740,6 +8740,7 @@
"stripebilling",
"taxjar",
"threedsecureio",
+ "tesouro",
"tokenex",
"tokenio",
"trustpay",
@@ -24051,6 +24052,7 @@
"stax",
"stripe",
"stripebilling",
+ "tesouro",
"trustpay",
"trustpayments",
"tokenio",
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index b23c9300ac..2128079b3d 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -384,6 +384,10 @@ debit = { country = "ID,PH", currency = "IDR,PHP,USD,SGD,MYR" }
credit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW, ZWL, BYN, KPW, STN, MRU, VES" }
debit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER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AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BRL,BSD,BTN,BWP,BYN,BZD,CAD,CDF,CHF,CLF,CLP,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLE,SLL,SOS,SRD,SSP,STD,STN,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW,ZWL" }
+
[pm_filters.billwerk]
credit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
debit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 3a2fb9baaf..c7c85bc1f8 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -395,6 +395,10 @@ debit = { country = "ID,PH", currency = "IDR,PHP,USD,SGD,MYR" }
credit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW, ZWL, BYN, KPW, STN, MRU, VES" }
debit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, V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VG,WF,YE,ZM,ZW", currency = "AED,AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BRL,BSD,BTN,BWP,BYN,BZD,CAD,CDF,CHF,CLF,CLP,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLE,SLL,SOS,SRD,SSP,STD,STN,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW,ZWL" }
+
[pm_filters.billwerk]
credit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
debit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index baaf09befd..916636bcc4 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -404,6 +404,10 @@ debit = { country = "ID,PH", currency = "IDR,PHP,USD,SGD,MYR" }
credit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW, ZWL, BYN, KPW, STN, MRU, VES" }
debit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TW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G,UA,AE,GB,US,UY,UZ,VU,VE,VN,VG,WF,YE,ZM,ZW", currency = "AED,AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BRL,BSD,BTN,BWP,BYN,BZD,CAD,CDF,CHF,CLF,CLP,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLE,SLL,SOS,SRD,SSP,STD,STN,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW,ZWL" }
+
[pm_filters.billwerk]
credit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
debit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
diff --git a/config/development.toml b/config/development.toml
index 63eeeb8fa1..a82fe46afd 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -843,6 +843,11 @@ instant_bank_transfer_poland = { country = "PL", currency = "PLN" }
instant_bank_transfer_finland = { country = "FI", currency = "EUR" }
sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,GB", currency = "EUR" }
+
+[pm_filters.tesouro]
+credit = { country = "AF,AL,DZ,AD,AO,AI,AG,AR,AM,AW,A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,BZD,CAD,CDF,CHF,CLF,CLP,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLE,SLL,SOS,SRD,SSP,STD,STN,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW,ZWL" }
+
[pm_filters.authorizedotnet]
credit = {currency = "CAD,USD"}
debit = {currency = "CAD,USD"}
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 30c9b64bd6..e4f7197c04 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -546,6 +546,10 @@ debit = { country = "ID,PH", currency = "IDR,PHP,USD,SGD,MYR" }
credit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW, ZWL, BYN, KPW, STN, MRU, VES" }
debit = { country = "NA", currency = "AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR, ZMW, ZWL, BYN, KPW, STN, MRU, VES" }
+[pm_filters.tesouro]
+credit = { country = "AF,AL,DZ,AD,AO,AI,AG,AR,AM,AW,AU,AT,AZ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,CDF,CHF,CLF,CLP,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLE,SLL,SOS,SRD,SSP,STD,STN,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW,ZWL" }
+
[pm_filters.billwerk]
credit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
debit = { country = "DE, DK, FR, SE", currency = "DKK, NOK" }
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index 2db7e7613d..51dc646942 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -156,6 +156,7 @@ pub enum RoutableConnectors {
Stax,
Stripe,
Stripebilling,
+ Tesouro,
// Taxjar,
Trustpay,
Trustpayments,
@@ -340,6 +341,7 @@ pub enum Connector {
Threedsecureio,
// Tokenio,
//Thunes,
+ Tesouro,
Tokenex,
Tokenio,
Trustpay,
@@ -409,6 +411,7 @@ impl Connector {
Self::Trustpay,
PaymentMethod::BankRedirect | PaymentMethod::BankTransfer
)
+ | (Self::Tesouro, _)
| (Self::Iatapay, _)
| (Self::Volt, _)
| (Self::Itaubank, _)
@@ -526,6 +529,7 @@ impl Connector {
| Self::Stax
| Self::Stripebilling
| Self::Taxjar
+ | Self::Tesouro
// | Self::Thunes
| Self::Trustpay
| Self::Trustpayments
@@ -714,6 +718,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Stax => Self::Stax,
RoutableConnectors::Stripe => Self::Stripe,
RoutableConnectors::Stripebilling => Self::Stripebilling,
+ RoutableConnectors::Tesouro => Self::Tesouro,
RoutableConnectors::Tokenio => Self::Tokenio,
RoutableConnectors::Trustpay => Self::Trustpay,
RoutableConnectors::Trustpayments => Self::Trustpayments,
@@ -850,6 +855,7 @@ impl TryFrom<Connector> for RoutableConnectors {
Connector::Stripe => Ok(Self::Stripe),
Connector::Stripebilling => Ok(Self::Stripebilling),
Connector::Tokenio => Ok(Self::Tokenio),
+ Connector::Tesouro => Ok(Self::Tesouro),
Connector::Trustpay => Ok(Self::Trustpay),
Connector::Trustpayments => Ok(Self::Trustpayments),
Connector::Tsys => Ok(Self::Tsys),
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index e69ba486c3..95594dfb4a 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -345,6 +345,7 @@ pub struct ConnectorConfig {
pub stripe_payout: Option<ConnectorTomlConfig>,
pub stripebilling: Option<ConnectorTomlConfig>,
pub signifyd: Option<ConnectorTomlConfig>,
+ pub tersouro: Option<ConnectorTomlConfig>,
pub tokenex: Option<ConnectorTomlConfig>,
pub tokenio: Option<ConnectorTomlConfig>,
pub trustpay: Option<ConnectorTomlConfig>,
@@ -555,6 +556,7 @@ impl ConnectorConfig {
Connector::Stax => Ok(connector_data.stax),
Connector::Stripe => Ok(connector_data.stripe),
Connector::Stripebilling => Ok(connector_data.stripebilling),
+ Connector::Tesouro => Ok(connector_data.tesouro),
Connector::Tokenex => Ok(connector_data.tokenex),
Connector::Tokenio => Ok(connector_data.tokenio),
Connector::Trustpay => Ok(connector_data.trustpay),
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index 1a1b9b1efb..f39b262078 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -7239,10 +7239,6 @@ type = "Text"
[finix.connector_auth.HeaderKey]
api_key = "API Key"
-[tesouro]
-[tesouro.connector_auth.BodyKey]
-api_key="Client ID"
-key1="Client Secret"
[loonio]
[loonio.connector_auth.BodyKey]
@@ -7250,3 +7246,40 @@ api_key = "Merchant ID"
api_secret = "Merchant Token"
[[loonio.bank_redirect]]
payment_method_type = "interac"
+
+
+[tesouro]
+[[tesouro.credit]]
+payment_method_type = "Mastercard"
+[[tesouro.credit]]
+payment_method_type = "Visa"
+[[tesouro.credit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.credit]]
+payment_method_type = "Discover"
+[[tesouro.credit]]
+payment_method_type = "DinersClub"
+[[tesouro.credit]]
+payment_method_type = "JCB"
+[[tesouro.credit]]
+payment_method_type = "Maestro"
+[[tesouro.credit]]
+payment_method_type = "UnionPay"
+[[tesouro.debit]]
+payment_method_type = "Mastercard"
+[[tesouro.debit]]
+payment_method_type = "Visa"
+[[tesouro.debit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.debit]]
+payment_method_type = "Discover"
+[[tesouro.debit]]
+payment_method_type = "DinersClub"
+[[tesouro.debit]]
+payment_method_type = "JCB"
+[[tesouro.debit]]
+payment_method_type = "Maestro"
+[tesouro.connector_auth.SignatureKey]
+api_key = "Client ID"
+api_secret = "Client Secret"
+key1 = "Acceptor ID"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index a65dcde1e2..1974b19770 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -5977,14 +5977,45 @@ type = "Text"
[finix.connector_auth.HeaderKey]
api_key = "API Key"
-[tesouro]
-[tesouro.connector_auth.BodyKey]
-api_key="Client ID"
-key1="Client Secret"
-
[loonio]
[loonio.connector_auth.BodyKey]
api_key = "Merchant ID"
api_secret = "Merchant Token"
[[loonio.bank_redirect]]
payment_method_type = "interac"
+
+[tesouro]
+[[tesouro.credit]]
+payment_method_type = "Mastercard"
+[[tesouro.credit]]
+payment_method_type = "Visa"
+[[tesouro.credit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.credit]]
+payment_method_type = "Discover"
+[[tesouro.credit]]
+payment_method_type = "DinersClub"
+[[tesouro.credit]]
+payment_method_type = "JCB"
+[[tesouro.credit]]
+payment_method_type = "Maestro"
+[[tesouro.credit]]
+payment_method_type = "UnionPay"
+[[tesouro.debit]]
+payment_method_type = "Mastercard"
+[[tesouro.debit]]
+payment_method_type = "Visa"
+[[tesouro.debit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.debit]]
+payment_method_type = "Discover"
+[[tesouro.debit]]
+payment_method_type = "DinersClub"
+[[tesouro.debit]]
+payment_method_type = "JCB"
+[[tesouro.debit]]
+payment_method_type = "Maestro"
+[tesouro.connector_auth.SignatureKey]
+api_key = "Client ID"
+api_secret = "Client Secret"
+key1 = "Acceptor ID"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 124286a88a..eb9f2875cc 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -7218,10 +7218,6 @@ type = "Text"
[finix.connector_auth.HeaderKey]
api_key = "API Key"
-[tesouro]
-[tesouro.connector_auth.BodyKey]
-api_key="Client ID"
-key1="Client Secret"
[loonio]
[loonio.connector_auth.BodyKey]
@@ -7229,3 +7225,40 @@ api_key = "Merchant ID"
api_secret = "Merchant Token"
[[loonio.bank_redirect]]
payment_method_type = "interac"
+
+
+[tesouro]
+[[tesouro.credit]]
+payment_method_type = "Mastercard"
+[[tesouro.credit]]
+payment_method_type = "Visa"
+[[tesouro.credit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.credit]]
+payment_method_type = "Discover"
+[[tesouro.credit]]
+payment_method_type = "DinersClub"
+[[tesouro.credit]]
+payment_method_type = "JCB"
+[[tesouro.credit]]
+payment_method_type = "Maestro"
+[[tesouro.credit]]
+payment_method_type = "UnionPay"
+[[tesouro.debit]]
+payment_method_type = "Mastercard"
+[[tesouro.debit]]
+payment_method_type = "Visa"
+[[tesouro.debit]]
+payment_method_type = "AmericanExpress"
+[[tesouro.debit]]
+payment_method_type = "Discover"
+[[tesouro.debit]]
+payment_method_type = "DinersClub"
+[[tesouro.debit]]
+payment_method_type = "JCB"
+[[tesouro.debit]]
+payment_method_type = "Maestro"
+[tesouro.connector_auth.SignatureKey]
+api_key = "Client ID"
+api_secret = "Client Secret"
+key1 = "Acceptor ID"
diff --git a/crates/hyperswitch_connectors/src/connectors/tesouro.rs b/crates/hyperswitch_connectors/src/connectors/tesouro.rs
index cdd0d81c6d..b05a5aef73 100644
--- a/crates/hyperswitch_connectors/src/connectors/tesouro.rs
+++ b/crates/hyperswitch_connectors/src/connectors/tesouro.rs
@@ -12,7 +12,7 @@ use common_utils::{
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
- router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
+ router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
@@ -24,11 +24,12 @@ use hyperswitch_domain_models::{
RefundsData, SetupMandateRequestData,
},
router_response_types::{
- ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,
+ ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
+ SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
- RefundSyncRouterData, RefundsRouterData,
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefreshTokenRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
@@ -37,15 +38,15 @@ use hyperswitch_interfaces::{
ConnectorValidation,
},
configs::Connectors,
- errors,
+ consts, errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks,
};
-use masking::{ExposeInterface, Mask};
+use masking::{Mask, PeekInterface};
use transformers as tesouro;
-use crate::{constants::headers, types::ResponseRouterData, utils};
+use crate::{constants::headers, types::ResponseRouterData, utils as connector_utils};
#[derive(Clone)]
pub struct Tesouro {
@@ -88,13 +89,22 @@ where
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- let mut header = vec![(
+ let mut headers = vec![(
headers::CONTENT_TYPE.to_string(),
- self.get_content_type().to_string().into(),
+ self.common_get_content_type().to_string().into(),
)];
- let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
- header.append(&mut api_key);
- Ok(header)
+ let access_token = req
+ .access_token
+ .clone()
+ .ok_or(errors::ConnectorError::FailedToObtainAuthType)?;
+
+ let auth_header = (
+ headers::AUTHORIZATION.to_string(),
+ format!("Bearer {}", access_token.token.peek()).into_masked(),
+ );
+
+ headers.push(auth_header);
+ Ok(headers)
}
}
@@ -105,9 +115,6 @@ impl ConnectorCommon for Tesouro {
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
- // TODO! Check connector documentation, on which unit they are processing the currency.
- // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
- // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
}
fn common_get_content_type(&self) -> &'static str {
@@ -118,43 +125,46 @@ impl ConnectorCommon for Tesouro {
connectors.tesouro.base_url.as_ref()
}
- fn get_auth_header(
- &self,
- auth_type: &ConnectorAuthType,
- ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- let auth = tesouro::TesouroAuthType::try_from(auth_type)
- .change_context(errors::ConnectorError::FailedToObtainAuthType)?;
- Ok(vec![(
- headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
- )])
- }
-
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
- let response: tesouro::TesouroErrorResponse = res
- .response
- .parse_struct("TesouroErrorResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
-
- event_builder.map(|i| i.set_response_body(&response));
- router_env::logger::info!(connector_response=?response);
-
- Ok(ErrorResponse {
- status_code: res.status_code,
- code: response.code,
- message: response.message,
- reason: response.reason,
- attempt_status: None,
- connector_transaction_id: None,
- network_advice_code: None,
- network_decline_code: None,
- network_error_message: None,
- connector_metadata: None,
- })
+ let status_code = res.status_code;
+ let response: Result<tesouro::TesouroGraphQlErrorResponse, _> =
+ res.response.parse_struct("TesouroGraphQlErrorResponse");
+
+ match response {
+ Ok(response) => {
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ let error = response.errors.first();
+ let error_extensions = error.and_then(|error_data| error_data.extensions.clone());
+
+ Ok(ErrorResponse {
+ status_code,
+ code: error_extensions
+ .as_ref()
+ .and_then(|ext| ext.code.clone())
+ .unwrap_or(consts::NO_ERROR_CODE.to_string()),
+ message: error
+ .map(|error_data| error_data.message.clone())
+ .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
+ reason: error_extensions.as_ref().and_then(|ext| ext.reason.clone()),
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ }
+ Err(error_msg) => {
+ event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": status_code})));
+ router_env::logger::error!(deserialization_error =? error_msg);
+ connector_utils::handle_json_response_deserialization_failure(res, "tesouro")
+ }
+ }
}
}
@@ -188,9 +198,132 @@ impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> fo
//TODO: implement sessions flow
}
-impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Tesouro {}
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Tesouro {
+ fn get_headers(
+ &self,
+ _req: &RefreshTokenRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let header = vec![(
+ headers::CONTENT_TYPE.to_string(),
+ types::RefreshTokenType::get_content_type(self)
+ .to_string()
+ .into(),
+ )];
+ Ok(header)
+ }
+
+ fn get_url(
+ &self,
+ _req: &RefreshTokenRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}/openid/connect/token",
+ self.base_url(connectors).to_owned()
+ ))
+ }
+
+ fn get_http_method(&self) -> Method {
+ Method::Post
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ mime::APPLICATION_WWW_FORM_URLENCODED.as_ref()
+ }
+
+ fn get_request_body(
+ &self,
+ req: &RefreshTokenRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = tesouro::TesouroAccessTokenRequest::try_from(req)?;
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &RefreshTokenRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ let req = Some(
+ RequestBuilder::new()
+ .method(types::RefreshTokenType::get_http_method(self))
+ .url(&types::RefreshTokenType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::RefreshTokenType::get_headers(self, req, connectors)?)
+ .set_body(types::RefreshTokenType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ );
+ Ok(req)
+ }
+ fn handle_response(
+ &self,
+ data: &RefreshTokenRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<RefreshTokenRouterData, errors::ConnectorError> {
+ let response: tesouro::TesouroAccessTokenResponse = res
+ .response
+ .parse_struct("tesouro TesouroAccessTokenResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
-impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Tesouro {}
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ let response: tesouro::TesouroAccessTokenErrorResponse = res
+ .response
+ .parse_struct("tesouro TesouroAccessTokenErrorResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response.error.clone(),
+ message: response
+ .error_description
+ .clone()
+ .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
+ reason: response.error_uri.clone(),
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ }
+}
+
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Tesouro {
+ fn build_request(
+ &self,
+ _req: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Err(
+ errors::ConnectorError::NotImplemented("Setup Mandate flow for Tesouro".to_string())
+ .into(),
+ )
+ }
+}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Tesouro {
fn get_headers(
@@ -205,12 +338,16 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
self.common_get_content_type()
}
+ fn get_http_method(&self) -> Method {
+ Method::Post
+ }
+
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
}
fn get_request_body(
@@ -218,14 +355,14 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let amount = utils::convert_amount(
+ let amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = tesouro::TesouroRouterData::from((amount, req));
- let connector_req = tesouro::TesouroPaymentsRequest::try_from(&connector_router_data)?;
+ let connector_req = tesouro::TesouroAuthorizeRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
@@ -236,7 +373,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Post)
+ .method(types::PaymentsAuthorizeType::get_http_method(self))
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
@@ -257,9 +394,9 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- let response: tesouro::TesouroPaymentsResponse = res
+ let response: tesouro::TesouroAuthorizeResponse = res
.response
- .parse_struct("Tesouro PaymentsAuthorizeResponse")
+ .parse_struct("Tesouro TesouroAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -295,9 +432,18 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tes
fn get_url(
&self,
_req: &PaymentsSyncRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = tesouro::TesouroSyncRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -307,10 +453,13 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tes
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Get)
+ .method(Method::Post)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsSyncType::get_request_body(
+ self, req, connectors,
+ )?)
.build(),
))
}
@@ -321,9 +470,9 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tes
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
- let response: tesouro::TesouroPaymentsResponse = res
+ let response: tesouro::TesouroSyncResponse = res
.response
- .parse_struct("tesouro PaymentsSyncResponse")
+ .parse_struct("tesouro TesouroSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -359,17 +508,25 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
fn get_url(
&self,
_req: &PaymentsCaptureRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
}
fn get_request_body(
&self,
- _req: &PaymentsCaptureRouterData,
+ req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ let amount = connector_utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount_to_capture,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = tesouro::TesouroRouterData::from((amount, req));
+ let connector_req = tesouro::TesouroCaptureRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -398,9 +555,9 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
- let response: tesouro::TesouroPaymentsResponse = res
+ let response: tesouro::TesouroCaptureResponse = res
.response
- .parse_struct("Tesouro PaymentsCaptureResponse")
+ .parse_struct("Tesouro TesouroCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -420,7 +577,81 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
}
}
-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Tesouro {}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Tesouro {
+ fn get_headers(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = tesouro::TesouroVoidRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsVoidType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCancelRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
+ let response: tesouro::TesouroVoidResponse = res
+ .response
+ .parse_struct("Tesouro TesouroVoidResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tesouro {
fn get_headers(
@@ -438,9 +669,9 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tesouro
fn get_url(
&self,
_req: &RefundsRouterData<Execute>,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
}
fn get_request_body(
@@ -448,7 +679,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tesouro
req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let refund_amount = utils::convert_amount(
+ let refund_amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_refund_amount,
req.request.currency,
@@ -484,9 +715,9 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tesouro
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
- let response: tesouro::RefundResponse = res
+ let response: tesouro::TesouroRefundResponse = res
.response
- .parse_struct("tesouro RefundResponse")
+ .parse_struct("tesouro TesouroRefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -522,9 +753,18 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Tesouro {
fn get_url(
&self,
_req: &RefundSyncRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/graphql", self.base_url(connectors).to_owned()))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &RefundSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = tesouro::TesouroSyncRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -534,7 +774,7 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Tesouro {
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Get)
+ .method(Method::Post)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
@@ -551,9 +791,9 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Tesouro {
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
- let response: tesouro::RefundResponse = res
+ let response: tesouro::TesouroSyncResponse = res
.response
- .parse_struct("tesouro RefundSyncResponse")
+ .parse_struct("tesouro TesouroSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -597,12 +837,69 @@ impl webhooks::IncomingWebhook for Tesouro {
}
}
-static TESOURO_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
- LazyLock::new(SupportedPaymentMethods::new);
+static TESOURO_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
+ let supported_capture_methods = vec![
+ enums::CaptureMethod::Automatic,
+ enums::CaptureMethod::Manual,
+ ];
+
+ let supported_card_network = vec![
+ common_enums::CardNetwork::Mastercard,
+ common_enums::CardNetwork::Visa,
+ common_enums::CardNetwork::AmericanExpress,
+ common_enums::CardNetwork::Discover,
+ common_enums::CardNetwork::DinersClub,
+ common_enums::CardNetwork::JCB,
+ common_enums::CardNetwork::Maestro,
+ common_enums::CardNetwork::UnionPay,
+ ];
+
+ let mut paysafe_supported_payment_methods = SupportedPaymentMethods::new();
+
+ paysafe_supported_payment_methods.add(
+ enums::PaymentMethod::Card,
+ enums::PaymentMethodType::Credit,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::NotSupported,
+ refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ paysafe_supported_payment_methods.add(
+ enums::PaymentMethod::Card,
+ enums::PaymentMethodType::Debit,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::NotSupported,
+ refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ paysafe_supported_payment_methods
+});
static TESOURO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Tesouro",
- description: "Tesouro connects software companies and banks in one unified ecosystem, simplifying payments",
+ description: "Tesouro is a Miami-based fintech company that provides a cloud-native payment gateway platform, offering APIs and streamlined data inflows to connect software companies, banks, and payment facilitators for seamless payment processing",
connector_type: enums::HyperswitchConnectorCategory::PaymentGateway,
integration_status: enums::ConnectorIntegrationStatus::Sandbox,
};
@@ -621,4 +918,22 @@ impl ConnectorSpecifications for Tesouro {
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&TESOURO_SUPPORTED_WEBHOOK_FLOWS)
}
+
+ #[cfg(feature = "v1")]
+ fn generate_connector_request_reference_id(
+ &self,
+ payment_intent: &hyperswitch_domain_models::payments::PaymentIntent,
+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
+ is_config_enabled_to_send_payment_id_as_connector_request_id: bool,
+ ) -> String {
+ if is_config_enabled_to_send_payment_id_as_connector_request_id
+ && payment_intent.is_payment_id_from_merchant.unwrap_or(false)
+ {
+ payment_attempt.payment_id.get_string_repr().to_owned()
+ } else {
+ let max_payment_reference_id_length =
+ tesouro::tesouro_constants::MAX_PAYMENT_REFERENCE_ID_LENGTH;
+ nanoid::nanoid!(max_payment_reference_id_length)
+ }
+ }
}
diff --git a/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs b/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs
index 89ca59873e..4749cc594b 100644
--- a/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs
@@ -1,28 +1,84 @@
use common_enums::enums;
use common_utils::types::FloatMajorUnit;
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
- payment_method_data::PaymentMethodData,
- router_data::{ConnectorAuthType, RouterData},
+ payment_method_data::{Card, PaymentMethodData},
+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::refunds::{Execute, RSync},
- router_request_types::ResponseId,
+ router_request_types::{
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,
+ ResponseId,
+ },
router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{PaymentsAuthorizeRouterData, RefundsRouterData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefreshTokenRouterData, RefundSyncRouterData, RefundsRouterData,
+ },
+};
+use hyperswitch_interfaces::{
+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
+ errors,
};
-use hyperswitch_interfaces::errors;
use masking::Secret;
use serde::{Deserialize, Serialize};
-use crate::types::{RefundsResponseRouterData, ResponseRouterData};
+use crate::{
+ types::{RefundsResponseRouterData, ResponseRouterData},
+ utils::{
+ self as connector_utils, CardData, PaymentsAuthorizeRequestData, PaymentsSyncRequestData,
+ RefundsRequestData, RouterData as _,
+ },
+};
+
+pub mod tesouro_queries {
+ pub const AUTHORIZE_TRANSACTION: &str = "mutation AuthorizeCustomerInitiatedTransaction($authorizeCustomerInitiatedTransactionInput: AuthorizeCustomerInitiatedTransactionInput!) { authorizeCustomerInitiatedTransaction(authorizeCustomerInitiatedTransactionInput: $authorizeCustomerInitiatedTransactionInput) { authorizationResponse { paymentId transactionId __typename ... on AuthorizationApproval { __typename paymentId transactionId } ... on AuthorizationDecline { __typename transactionId paymentId } } errors { ... on InternalServiceError { message transactionId processorResponseCode } ... on AcceptorNotFoundError { message transactionId processorResponseCode } ... on RuleInViolationError { message transactionId processorResponseCode } ... on SyntaxOnNetworkResponseError { message transactionId processorResponseCode } ... on TimeoutOnNetworkResponseError { message transactionId processorResponseCode } ... on ValidationFailureError { message processorResponseCode transactionId } ... on UnknownCardError { message processorResponseCode transactionId } ... on TokenNotFoundError { message processorResponseCode transactionId } ... on InvalidTokenError { message processorResponseCode transactionId } ... on RouteNotFoundError { message processorResponseCode transactionId } } } }";
+ pub const CAPTURE_TRANSACTION: &str = "mutation CaptureAuthorization($captureAuthorizationInput: CaptureAuthorizationInput!) { captureAuthorization(captureAuthorizationInput: $captureAuthorizationInput) { captureAuthorizationResponse { __typename ... on CaptureAuthorizationApproval { __typename paymentId transactionId } ... on CaptureAuthorizationDecline { __typename paymentId transactionId } } errors { ... on InternalServiceError { message processorResponseCode transactionId } ... on RuleInViolationError { message processorResponseCode transactionId } ... on SyntaxOnNetworkResponseError { message processorResponseCode transactionId } ... on TimeoutOnNetworkResponseError { message processorResponseCode transactionId } ... on ValidationFailureError { message processorResponseCode transactionId} ... on PriorPaymentNotFoundError { message processorResponseCode transactionId } } } }";
+ pub const VOID_TRANSACTION: &str = "mutation ReverseTransaction($reverseTransactionInput: ReverseTransactionInput!) { reverseTransaction(reverseTransactionInput: $reverseTransactionInput) { errors { ... on InternalServiceError { message processorResponseCode transactionId } ... on RuleInViolationError { message processorResponseCode transactionId } ... on SyntaxOnNetworkResponseError { message processorResponseCode transactionId } ... on TimeoutOnNetworkResponseError { message processorResponseCode transactionId } ... on ValidationFailureError { message processorResponseCode transactionId } ... on PriorTransactionNotFoundError { message processorResponseCode transactionId } } reverseTransactionResponse { paymentId transactionId ... on ReverseTransactionApproval { paymentId transactionId } ... on ReverseTransactionDecline { message paymentId transactionId declineType } } } }";
+ pub const REFUND_TRANSACTION: &str = "mutation RefundPreviousPayment($refundPreviousPaymentInput: RefundPreviousPaymentInput!) { refundPreviousPayment(refundPreviousPaymentInput: $refundPreviousPaymentInput) { errors { ... on InternalServiceError { message processorResponseCode transactionId } ... on RuleInViolationError { processorResponseCode message transactionId } ... on SyntaxOnNetworkResponseError { message processorResponseCode transactionId } ... on TimeoutOnNetworkResponseError { processorResponseCode message transactionId } ... on ValidationFailureError { message processorResponseCode transactionId } ... on PriorPaymentNotFoundError { message processorResponseCode transactionId } } refundPreviousPaymentResponse { __typename ... on RefundPreviousPaymentApproval { __typename paymentId transactionId } ... on RefundPreviousPaymentDecline { __typename declineType message transactionId paymentId } } } }";
+ pub const SYNC_TRANSACTION: &str = "query PaymentTransaction($paymentTransactionId: UUID!) { paymentTransaction(id: $paymentTransactionId) { __typename responseType reference id paymentId ... on AcceptedSale { __typename id processorResponseCode processorResponseMessage } ... on ApprovedAuthorization { __typename id processorResponseCode processorResponseMessage } ... on ApprovedCapture { __typename id processorResponseCode processorResponseMessage } ... on ApprovedReversal { __typename id processorResponseCode processorResponseMessage } ... on DeclinedAuthorization { __typename id processorResponseCode processorResponseMessage } ... on DeclinedCapture { __typename id processorResponseCode processorResponseMessage } ... on DeclinedReversal { __typename id processorResponseCode processorResponseMessage } ... on GenericPaymentTransaction { __typename id processorResponseCode processorResponseMessage } ... on Authorization { __typename id processorResponseCode processorResponseMessage } ... on Capture { __typename id processorResponseCode processorResponseMessage } ... on Reversal { __typename id processorResponseCode processorResponseMessage } ... on Sale { __typename id processorResponseCode processorResponseMessage } } }";
+}
+
+pub mod tesouro_constants {
+ pub const MAX_PAYMENT_REFERENCE_ID_LENGTH: usize = 28;
+}
+
+#[derive(Debug, Clone, Serialize)]
+pub struct GenericTesouroRequest<T> {
+ query: String,
+ variables: T,
+}
+
+pub type TesouroAuthorizeRequest = GenericTesouroRequest<TesouroAuthorizeInput>;
+pub type TesouroCaptureRequest = GenericTesouroRequest<TesouroCaptureInput>;
+pub type TesouroVoidRequest = GenericTesouroRequest<TesouroVoidInput>;
+pub type TesouroRefundRequest = GenericTesouroRequest<TesouroRefundInput>;
+pub type TesouroSyncRequest = GenericTesouroRequest<TesouroSyncInput>;
+
+pub type TesouroAuthorizeResponse = TesouroApiResponse<TesouroAuthorizeResponseData>;
+pub type TesouroCaptureResponse = TesouroApiResponse<TesouroCaptureResponseData>;
+pub type TesouroVoidResponse = TesouroApiResponse<TesouroVoidResponseData>;
+pub type TesouroRefundResponse = TesouroApiResponse<RefundTransactionResponseData>;
+pub type TesouroSyncResponse = TesouroApiResponse<TesouroSyncResponseData>;
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum TesouroApiResponse<T> {
+ TesouroApiSuccessResponse(TesouroApiResponseData<T>),
+ TesouroErrorResponse(TesouroApiErrorResponse),
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroApiResponseData<T> {
+ data: T,
+}
-//TODO: Fill the struct with respective fields
pub struct TesouroRouterData<T> {
- pub amount: FloatMajorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub amount: FloatMajorUnit,
pub router_data: T,
}
impl<T> From<(FloatMajorUnit, T)> for TesouroRouterData<T> {
fn from((amount, item): (FloatMajorUnit, T)) -> Self {
- //Todo : use utils to convert the amount to the type of amount that a connector accepts
Self {
amount,
router_data: item,
@@ -30,190 +86,1513 @@ impl<T> From<(FloatMajorUnit, T)> for TesouroRouterData<T> {
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, PartialEq)]
-pub struct TesouroPaymentsRequest {
- amount: FloatMajorUnit,
- card: TesouroCard,
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TransactionResponseData<T> {
+ #[serde(rename = "__typename")]
+ pub type_name: Option<T>,
+ pub payment_id: Option<String>,
+ pub transaction_id: String,
+ pub decline_type: Option<String>,
+ pub message: Option<String>,
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct TesouroCard {
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroAuthorizeResponseData {
+ authorize_customer_initiated_transaction: AuthorizeCustomerInitiatedTransactionResponseData,
}
-impl TryFrom<&TesouroRouterData<&PaymentsAuthorizeRouterData>> for TesouroPaymentsRequest {
- type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- item: &TesouroRouterData<&PaymentsAuthorizeRouterData>,
- ) -> Result<Self, Self::Error> {
- match item.router_data.request.payment_method_data.clone() {
- PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
- "Card payment method not implemented".to_string(),
- )
- .into()),
- _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
- }
- }
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub enum AuthorizeTransactionResponseType {
+ AuthorizationApproval,
+ AuthorizationDecline,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct AuthorizeCustomerInitiatedTransactionResponseData {
+ authorization_response: Option<TransactionResponseData<AuthorizeTransactionResponseType>>,
+ errors: Option<Vec<TesouroTransactionErrorResponseData>>,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroCaptureResponseData {
+ capture_authorization: CaptureCustomerInitiatedTransactionResponseData,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CaptureCustomerInitiatedTransactionResponseData {
+ capture_authorization_response: Option<TransactionResponseData<CaptureTransactionResponseType>>,
+ errors: Option<Vec<TesouroTransactionErrorResponseData>>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub enum CaptureTransactionResponseType {
+ CaptureAuthorizationApproval,
+ CaptureAuthorizationDecline,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroVoidResponseData {
+ reverse_transaction: ReverseTransactionResponseData,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ReverseTransactionResponseData {
+ reverse_transaction_response: Option<TransactionResponseData<ReverseTransactionResponseType>>,
+ errors: Option<Vec<TesouroTransactionErrorResponseData>>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub enum ReverseTransactionResponseType {
+ ReverseTransactionApproval,
+ ReverseTransactionDecline,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RefundTransactionResponseData {
+ refund_previous_payment: TesouroRefundPreviousPaymentResponseData,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroRefundPreviousPaymentResponseData {
+ refund_previous_payment_response:
+ Option<TransactionResponseData<RefundTransactionResponseType>>,
+ errors: Option<Vec<TesouroTransactionErrorResponseData>>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub enum RefundTransactionResponseType {
+ RefundPreviousPaymentApproval,
+ RefundPreviousPaymentDecline,
}
-//TODO: Fill the struct with respective fields
-// Auth Struct
pub struct TesouroAuthType {
- pub(super) api_key: Secret<String>,
+ pub(super) client_id: Secret<String>,
+ pub(super) client_secret: Secret<String>,
+ pub(super) acceptor_id: Secret<String>,
+}
+
+impl TesouroAuthType {
+ fn get_acceptor_id(&self) -> Secret<String> {
+ self.acceptor_id.clone()
+ }
}
impl TryFrom<&ConnectorAuthType> for TesouroAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
- ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
- api_key: api_key.to_owned(),
+ ConnectorAuthType::SignatureKey {
+ api_key,
+ api_secret,
+ key1,
+ } => Ok(Self {
+ client_id: api_key.to_owned(),
+ client_secret: api_secret.to_owned(),
+ acceptor_id: key1.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
}
}
}
-// PaymentsResponse
-//TODO: Append the remaining status flags
-#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)]
-#[serde(rename_all = "lowercase")]
-pub enum TesouroPaymentStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroApiErrorResponse {
+ errors: Vec<TesouroApiErrorData>,
}
-impl From<TesouroPaymentStatus> for common_enums::AttemptStatus {
- fn from(item: TesouroPaymentStatus) -> Self {
- match item {
- TesouroPaymentStatus::Succeeded => Self::Charged,
- TesouroPaymentStatus::Failed => Self::Failure,
- TesouroPaymentStatus::Processing => Self::Authorizing,
- }
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroApiErrorData {
+ message: String,
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub struct TesouroAccessTokenRequest {
+ grant_type: TesouroGrantType,
+ client_id: Secret<String>,
+ client_secret: Secret<String>,
+}
+
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum TesouroGrantType {
+ ClientCredentials,
+}
+
+impl TryFrom<&RefreshTokenRouterData> for TesouroAccessTokenRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &RefreshTokenRouterData) -> Result<Self, Self::Error> {
+ let auth = TesouroAuthType::try_from(&item.connector_auth_type)?;
+ Ok(Self {
+ grant_type: TesouroGrantType::ClientCredentials,
+ client_id: auth.client_id,
+ client_secret: auth.client_secret,
+ })
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
-pub struct TesouroPaymentsResponse {
- status: TesouroPaymentStatus,
- id: String,
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub struct TesouroAccessTokenResponse {
+ access_token: Secret<String>,
+ token_type: String,
+ expires_in: i64,
}
-impl<F, T> TryFrom<ResponseRouterData<F, TesouroPaymentsResponse, T, PaymentsResponseData>>
- for RouterData<F, T, PaymentsResponseData>
+impl<F, T> TryFrom<ResponseRouterData<F, TesouroAccessTokenResponse, T, AccessToken>>
+ for RouterData<F, T, AccessToken>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: ResponseRouterData<F, TesouroPaymentsResponse, T, PaymentsResponseData>,
+ item: ResponseRouterData<F, TesouroAccessTokenResponse, T, AccessToken>,
) -> Result<Self, Self::Error> {
Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(item.response.id),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata: None,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charges: None,
+ response: Ok(AccessToken {
+ token: item.response.access_token,
+ expires: item.response.expires_in,
}),
..item.data
})
}
}
-//TODO: Fill the struct with respective fields
-// REFUND :
-// Type definition for RefundRequest
-#[derive(Default, Debug, Serialize)]
-pub struct TesouroRefundRequest {
- pub amount: FloatMajorUnit,
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroAuthorizeInput {
+ pub authorize_customer_initiated_transaction_input: AuthorizeCustomerInitiatedTransactionInput,
}
-impl<F> TryFrom<&TesouroRouterData<&RefundsRouterData<F>>> for TesouroRefundRequest {
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroCaptureInput {
+ pub capture_authorization_input: CaptureAuthorizationInput,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroVoidInput {
+ pub reverse_transaction_input: ReverseTransactionInput,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroRefundInput {
+ pub refund_previous_payment_input: RefundPreviousPaymentInput,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroSyncInput {
+ pub payment_transaction_id: String,
+}
+
+#[derive(Debug, Clone, Copy, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum TesouroAuthorizationIntent {
+ FinalAuthorization,
+ PreAuthorization,
+}
+
+#[derive(Debug, Clone, Copy, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum TesouroChannel {
+ Ecommerce,
+ MailOrderTelephoneOrder,
+ Retail,
+}
+
+#[derive(Debug, Clone, Copy, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum TesouroAutomaticCapture {
+ Never,
+ OnApproval,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub enum TesouroPaymentMethodDetails {
+ CardWithPanDetails(TesouroCardWithPanDetails),
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroCardWithPanDetails {
+ pub expiration_month: Secret<String>,
+ pub expiration_year: Secret<String>,
+ pub account_number: cards::CardNumber,
+ pub payment_entry_mode: TesouroPaymentEntryMode,
+ pub security_code: TesouroSecurityCode,
+}
+
+#[derive(Debug, Clone, Copy, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum TesouroPaymentEntryMode {
+ PaymentMethodNotOnFile,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct TesouroSecurityCode {
+ pub value: Secret<String>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TransactionAmountDetails {
+ pub total_amount: FloatMajorUnit,
+ pub currency: enums::Currency,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BillToAddress {
+ pub address1: Option<Secret<String>>,
+ pub address2: Option<Secret<String>>,
+ pub address3: Option<Secret<String>>,
+ pub city: Option<String>,
+ pub country_code: Option<common_enums::CountryAlpha3>,
+ pub first_name: Option<Secret<String>>,
+ pub last_name: Option<Secret<String>>,
+ pub postal_code: Option<Secret<String>>,
+ pub state: Option<Secret<String>>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct AuthorizeCustomerInitiatedTransactionInput {
+ pub acceptor_id: Secret<String>,
+ pub transaction_reference: String,
+ pub payment_method_details: TesouroPaymentMethodDetails,
+ pub transaction_amount_details: TransactionAmountDetails,
+ pub automatic_capture: TesouroAutomaticCapture,
+ pub authorization_intent: TesouroAuthorizationIntent,
+ pub bill_to_address: BillToAddress,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CaptureAuthorizationInput {
+ pub acceptor_id: Secret<String>,
+ pub payment_id: String,
+ pub transaction_reference: String,
+ pub transaction_amount_details: TransactionAmountDetails,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ReverseTransactionInput {
+ pub acceptor_id: Secret<String>,
+ pub transaction_id: String,
+ pub transaction_reference: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RefundPreviousPaymentInput {
+ pub acceptor_id: Secret<String>,
+ pub payment_id: String,
+ pub transaction_reference: String,
+ pub transaction_amount_details: TransactionAmountDetails,
+}
+
+impl TryFrom<&Card> for TesouroPaymentMethodDetails {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &TesouroRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ fn try_from(value: &Card) -> Result<Self, Self::Error> {
+ let card_data = TesouroCardWithPanDetails {
+ expiration_month: value.get_card_expiry_month_2_digit()?,
+ expiration_year: value.get_expiry_year_4_digit(),
+ account_number: value.card_number.clone(),
+ payment_entry_mode: TesouroPaymentEntryMode::PaymentMethodNotOnFile,
+ security_code: TesouroSecurityCode {
+ value: value.card_cvc.clone(),
+ },
+ };
+
+ Ok(Self::CardWithPanDetails(card_data))
+ }
+}
+
+pub struct TesouroCaptureData {
+ automatic_capture: TesouroAutomaticCapture,
+ authorization_intent: TesouroAuthorizationIntent,
+}
+
+impl From<bool> for TesouroCaptureData {
+ fn from(is_auto_capture: bool) -> Self {
+ if is_auto_capture {
+ Self {
+ automatic_capture: TesouroAutomaticCapture::OnApproval,
+ authorization_intent: TesouroAuthorizationIntent::FinalAuthorization,
+ }
+ } else {
+ Self {
+ automatic_capture: TesouroAutomaticCapture::Never,
+ authorization_intent: TesouroAuthorizationIntent::PreAuthorization,
+ }
+ }
+ }
+}
+
+impl From<&PaymentsAuthorizeRouterData> for BillToAddress {
+ fn from(router_data: &PaymentsAuthorizeRouterData) -> Self {
+ Self {
+ address1: router_data.get_optional_billing_line1(),
+ address2: router_data.get_optional_billing_line2(),
+ address3: router_data.get_optional_billing_line3(),
+ city: router_data.get_optional_billing_city(),
+ country_code: router_data
+ .get_optional_billing_country()
+ .map(|billing_country| {
+ common_enums::CountryAlpha2::from_alpha2_to_alpha3(billing_country)
+ }),
+ first_name: router_data.get_optional_billing_first_name(),
+ last_name: router_data.get_optional_billing_last_name(),
+ postal_code: router_data.get_optional_billing_zip(),
+ state: router_data.get_optional_billing_state(),
+ }
+ }
+}
+
+impl TryFrom<&TesouroRouterData<&PaymentsAuthorizeRouterData>> for TesouroAuthorizeRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &TesouroRouterData<&PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ if item.router_data.is_three_ds() {
+ Err(errors::ConnectorError::NotSupported {
+ message: "Cards 3DS".to_string(),
+ connector: "Tesouro",
+ })?
+ }
+
+ let auth = TesouroAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let acceptor_id = auth.get_acceptor_id();
+ let transaction_reference =
+ get_valid_transaction_id(item.router_data.connector_request_reference_id.clone())?;
+ let capture_data = TesouroCaptureData::from(item.router_data.request.is_auto_capture()?);
+
+ let payment_method_details = match &item.router_data.request.payment_method_data {
+ PaymentMethodData::Card(card) => TesouroPaymentMethodDetails::try_from(card),
+ PaymentMethodData::CardDetailsForNetworkTransactionId(_)
+ | PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::Wallet(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::BankTransfer(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::CardToken(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::NetworkToken(_)
+ | PaymentMethodData::MobilePayment(_) => Err(errors::ConnectorError::NotImplemented(
+ connector_utils::get_unimplemented_payment_method_error_message("tesouro"),
+ )
+ .into()),
+ }?;
+
+ let bill_to_address = BillToAddress::from(item.router_data);
+
+ Ok(Self {
+ query: tesouro_queries::AUTHORIZE_TRANSACTION.to_string(),
+ variables: TesouroAuthorizeInput {
+ authorize_customer_initiated_transaction_input:
+ AuthorizeCustomerInitiatedTransactionInput {
+ acceptor_id,
+ transaction_reference,
+ payment_method_details,
+ transaction_amount_details: TransactionAmountDetails {
+ total_amount: item.amount,
+ currency: item.router_data.request.currency,
+ },
+ automatic_capture: capture_data.automatic_capture,
+ authorization_intent: capture_data.authorization_intent,
+ bill_to_address,
+ },
+ },
+ })
+ }
+}
+
+impl TryFrom<&TesouroRouterData<&PaymentsCaptureRouterData>> for TesouroCaptureRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &TesouroRouterData<&PaymentsCaptureRouterData>) -> Result<Self, Self::Error> {
+ let auth = TesouroAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let payment_metadata = item
+ .router_data
+ .request
+ .connector_meta
+ .clone()
+ .map(|payment_metadata| {
+ connector_utils::to_connector_meta::<TesouroTransactionMetadata>(Some(
+ payment_metadata,
+ ))
+ })
+ .transpose()?;
+
+ let payment_id = payment_metadata
+ .ok_or(errors::ConnectorError::NoConnectorMetaData)?
+ .payment_id;
+
+ let transaction_id =
+ get_valid_transaction_id(item.router_data.connector_request_reference_id.clone())?;
+
+ Ok(Self {
+ query: tesouro_queries::CAPTURE_TRANSACTION.to_string(),
+ variables: TesouroCaptureInput {
+ capture_authorization_input: CaptureAuthorizationInput {
+ acceptor_id: auth.get_acceptor_id(),
+ payment_id,
+ transaction_reference: format!("capture_{transaction_id}"),
+ transaction_amount_details: TransactionAmountDetails {
+ total_amount: item.amount,
+ currency: item.router_data.request.currency,
+ },
+ },
+ },
+ })
+ }
+}
+
+impl TryFrom<&PaymentsCancelRouterData> for TesouroVoidRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
+ let auth = TesouroAuthType::try_from(&item.connector_auth_type)?;
+ let transaction_id = get_valid_transaction_id(item.connector_request_reference_id.clone())?;
Ok(Self {
- amount: item.amount.to_owned(),
+ query: tesouro_queries::VOID_TRANSACTION.to_string(),
+ variables: TesouroVoidInput {
+ reverse_transaction_input: ReverseTransactionInput {
+ acceptor_id: auth.get_acceptor_id(),
+ transaction_id: item.request.connector_transaction_id.clone(),
+ transaction_reference: format!("rev_{transaction_id}"),
+ },
+ },
})
}
}
-// Type definition for Refund Response
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroApprovalResponse {
+ pub payment_id: String,
+ pub transaction_id: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroDeclineResponse {
+ pub payment_id: Option<String>,
+ pub transaction_id: Option<String>,
+ pub decline_type: String,
+ pub message: Option<String>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroTransactionErrorResponseData {
+ pub message: String,
+ pub processor_response_code: Option<String>,
+ pub transaction_id: Option<String>,
+}
-#[allow(dead_code)]
-#[derive(Debug, Copy, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroTransactionMetadata {
+ pub payment_id: String,
}
-impl From<RefundStatus> for enums::RefundStatus {
- fn from(item: RefundStatus) -> Self {
- match item {
- RefundStatus::Succeeded => Self::Success,
- RefundStatus::Failed => Self::Failure,
- RefundStatus::Processing => Self::Pending,
- //TODO: Review mapping
+impl<F>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ TesouroAuthorizeResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ TesouroAuthorizeResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ if let Some(authorization_response) = response
+ .data
+ .authorize_customer_initiated_transaction
+ .authorization_response
+ {
+ let transaction_id = authorization_response.transaction_id;
+ let connector_metadata = serde_json::json!(TesouroTransactionMetadata {
+ payment_id: authorization_response
+ .payment_id
+ .clone()
+ .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?,
+ });
+ match authorization_response.type_name {
+ Some(AuthorizeTransactionResponseType::AuthorizationApproval) => Ok(Self {
+ status: if item.data.request.is_auto_capture()? {
+ enums::AttemptStatus::Charged
+ } else {
+ enums::AttemptStatus::Authorized
+ },
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: Some(connector_metadata),
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ Some(AuthorizeTransactionResponseType::AuthorizationDecline) => Ok(Self {
+ status: if item.data.request.is_auto_capture()? {
+ enums::AttemptStatus::Failure
+ } else {
+ enums::AttemptStatus::AuthorizationFailed
+ },
+ response: Err(ErrorResponse {
+ code: authorization_response
+ .decline_type
+ .clone()
+ .unwrap_or(NO_ERROR_CODE.to_string()),
+ message: authorization_response
+ .message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: authorization_response.message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: Some(transaction_id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ }),
+ None => Ok(Self {
+ status: enums::AttemptStatus::Pending,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: Some(connector_metadata),
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ }
+ } else if let Some(errors) = response
+ .data
+ .authorize_customer_initiated_transaction
+ .errors
+ {
+ let error_response = errors.first();
+ let error_code = error_response
+ .as_ref()
+ .and_then(|error_data| error_data.processor_response_code.clone())
+ .unwrap_or(NO_ERROR_CODE.to_string());
+ let error_message = error_response
+ .as_ref()
+ .map(|error_data| error_data.message.clone());
+ let connector_transaction_id = error_response
+ .as_ref()
+ .and_then(|error_data| error_data.transaction_id.clone());
+
+ Ok(Self {
+ status: if item.data.request.is_auto_capture()? {
+ enums::AttemptStatus::Failure
+ } else {
+ enums::AttemptStatus::AuthorizationFailed
+ },
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from(
+ "Expected either error or authorization_response".to_string(),
+ ),
+ ))?
+ }
+ }
+ TesouroAuthorizeResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ status: if item.data.request.is_auto_capture()? {
+ enums::AttemptStatus::Failure
+ } else {
+ enums::AttemptStatus::AuthorizationFailed
+ },
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct RefundResponse {
- id: String,
- status: RefundStatus,
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroAccessTokenErrorResponse {
+ pub error: String,
+ pub error_description: Option<String>,
+ pub error_uri: Option<String>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroGraphQlErrorResponse {
+ pub errors: Vec<TesouroGraphQlError>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroGraphQlError {
+ pub message: String,
+ pub extensions: Option<TesouroGraphQlErrorExtensions>,
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct TesouroGraphQlErrorExtensions {
+ pub code: Option<String>,
+ pub reason: Option<String>,
+}
+
+impl<F>
+ TryFrom<
+ ResponseRouterData<F, TesouroCaptureResponse, PaymentsCaptureData, PaymentsResponseData>,
+ > for RouterData<F, PaymentsCaptureData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ TesouroCaptureResponse,
+ PaymentsCaptureData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ if let Some(capture_authorization_response) = response
+ .data
+ .capture_authorization
+ .capture_authorization_response
+ {
+ let transaction_id = capture_authorization_response.transaction_id;
+ match capture_authorization_response.type_name {
+ Some(CaptureTransactionResponseType::CaptureAuthorizationApproval) => {
+ Ok(Self {
+ status: enums::AttemptStatus::Charged,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ Some(CaptureTransactionResponseType::CaptureAuthorizationDecline) => {
+ Ok(Self {
+ status: enums::AttemptStatus::CaptureFailed,
+ response: Err(ErrorResponse {
+ code: capture_authorization_response
+ .decline_type
+ .clone()
+ .unwrap_or(NO_ERROR_CODE.to_string()),
+ message: capture_authorization_response
+ .message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: capture_authorization_response.message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: Some(transaction_id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ None => Ok(Self {
+ status: enums::AttemptStatus::CaptureInitiated,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ }
+ } else if let Some(errors) = response.data.capture_authorization.errors {
+ let error_response = errors.first();
+ let error_code = error_response
+ .as_ref()
+ .and_then(|error_data| error_data.processor_response_code.clone())
+ .unwrap_or(NO_ERROR_CODE.to_string());
+ let error_message = error_response
+ .as_ref()
+ .map(|error_data| error_data.message.clone());
+
+ Ok(Self {
+ status: enums::AttemptStatus::CaptureFailed,
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from(
+ "Expected either error or capture_authorization_response".to_string(),
+ ),
+ ))?
+ }
+ }
+ TesouroApiResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ status: enums::AttemptStatus::CaptureFailed,
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
}
-impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
+impl<F>
+ TryFrom<ResponseRouterData<F, TesouroVoidResponse, PaymentsCancelData, PaymentsResponseData>>
+ for RouterData<F, PaymentsCancelData, PaymentsResponseData>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<Execute, RefundResponse>,
+ item: ResponseRouterData<F, TesouroVoidResponse, PaymentsCancelData, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ if let Some(reverse_transaction) = response
+ .data
+ .reverse_transaction
+ .reverse_transaction_response
+ {
+ let transaction_id = reverse_transaction.transaction_id;
+ match reverse_transaction.type_name {
+ Some(ReverseTransactionResponseType::ReverseTransactionApproval) => {
+ Ok(Self {
+ status: enums::AttemptStatus::Voided,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ Some(ReverseTransactionResponseType::ReverseTransactionDecline) => {
+ Ok(Self {
+ status: enums::AttemptStatus::VoidFailed,
+ response: Err(ErrorResponse {
+ code: reverse_transaction
+ .decline_type
+ .clone()
+ .unwrap_or(NO_ERROR_CODE.to_string()),
+ message: reverse_transaction
+ .message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: reverse_transaction.message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: Some(transaction_id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ None => Ok(Self {
+ status: enums::AttemptStatus::VoidInitiated,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ }
+ } else if let Some(errors) = response.data.reverse_transaction.errors {
+ let error_response = errors.first();
+ let error_code = error_response
+ .as_ref()
+ .and_then(|error_data| error_data.processor_response_code.clone())
+ .unwrap_or(NO_ERROR_CODE.to_string());
+ let error_message = error_response
+ .as_ref()
+ .map(|error_data| error_data.message.clone());
+
+ Ok(Self {
+ status: enums::AttemptStatus::VoidFailed,
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from(
+ "Expected either error or reverse_transaction_response".to_string(),
+ ),
+ ))?
+ }
+ }
+ TesouroApiResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ status: enums::AttemptStatus::VoidFailed,
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+impl<F> TryFrom<&TesouroRouterData<&RefundsRouterData<F>>> for TesouroRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &TesouroRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ let auth = TesouroAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let payment_metadata = item
+ .router_data
+ .request
+ .connector_metadata
+ .clone()
+ .map(|payment_metadata| {
+ connector_utils::to_connector_meta::<TesouroTransactionMetadata>(Some(
+ payment_metadata,
+ ))
+ })
+ .transpose()?;
+
+ let payment_id = payment_metadata
+ .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?
+ .payment_id;
+
+ let transaction_reference =
+ get_valid_transaction_id(item.router_data.connector_request_reference_id.clone())?;
+
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ query: tesouro_queries::REFUND_TRANSACTION.to_string(),
+ variables: TesouroRefundInput {
+ refund_previous_payment_input: RefundPreviousPaymentInput {
+ acceptor_id: auth.get_acceptor_id(),
+ payment_id,
+ transaction_reference,
+ transaction_amount_details: TransactionAmountDetails {
+ total_amount: item.amount,
+ currency: item.router_data.request.currency,
+ },
+ },
+ },
})
}
}
-impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+impl TryFrom<RefundsResponseRouterData<Execute, TesouroRefundResponse>>
+ for RefundsRouterData<Execute>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<RSync, RefundResponse>,
+ item: RefundsResponseRouterData<Execute, TesouroRefundResponse>,
) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ if let Some(refund_previous_payment_response) = response
+ .data
+ .refund_previous_payment
+ .refund_previous_payment_response
+ {
+ let transaction_id = refund_previous_payment_response.transaction_id;
+ match refund_previous_payment_response.type_name {
+ Some(RefundTransactionResponseType::RefundPreviousPaymentApproval) => {
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: transaction_id,
+ refund_status: enums::RefundStatus::Success,
+ }),
+ ..item.data
+ })
+ }
+ Some(RefundTransactionResponseType::RefundPreviousPaymentDecline) => {
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: refund_previous_payment_response
+ .decline_type
+ .clone()
+ .unwrap_or(NO_ERROR_CODE.to_string()),
+ message: refund_previous_payment_response
+ .message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: refund_previous_payment_response.message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ None => Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: transaction_id,
+ refund_status: enums::RefundStatus::Pending,
+ }),
+ ..item.data
+ }),
+ }
+ } else if let Some(errors) = response.data.refund_previous_payment.errors {
+ let error_response = errors.first();
+ let error_code = error_response
+ .as_ref()
+ .and_then(|error_data| error_data.processor_response_code.clone())
+ .unwrap_or(NO_ERROR_CODE.to_string());
+ let error_message = error_response
+ .as_ref()
+ .map(|error_data| error_data.message.clone());
+
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from(
+ "Expected either error or refund_previous_payment_response".to_string(),
+ ),
+ ))?
+ }
+ }
+ TesouroApiResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroSyncResponseData {
+ payment_transaction: TesouroPaymentTransactionResponse,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TesouroPaymentTransactionResponse {
+ pub id: String,
+ #[serde(rename = "__typename")]
+ pub typename: TesouroSyncStatus,
+ #[serde(rename = "processorResponseCode")]
+ pub processor_response_code: Option<String>,
+ #[serde(rename = "processorResponseMessage")]
+ pub processor_response_message: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum TesouroSyncStatus {
+ AcceptedSale,
+ ApprovedAuthorization,
+ ApprovedCapture,
+ ApprovedReversal,
+ DeclinedAuthorization,
+ DeclinedCapture,
+ DeclinedReversal,
+ GenericPaymentTransaction,
+ Authorization,
+ Capture,
+ Reversal,
+ ApprovedRefund,
+ ApprovedRefundAuthorization,
+ DeclinedRefund,
+ DeclinedRefundAuthorization,
+ Refund,
+ RefundAuthorization,
+}
+
+fn get_payment_attempt_status(
+ status: TesouroSyncStatus,
+ is_auto_capture: bool,
+ previous_status: enums::AttemptStatus,
+) -> Result<enums::AttemptStatus, errors::ConnectorError> {
+ match status {
+ TesouroSyncStatus::AcceptedSale | TesouroSyncStatus::ApprovedCapture => {
+ Ok(enums::AttemptStatus::Charged)
+ }
+ TesouroSyncStatus::ApprovedAuthorization => {
+ if is_auto_capture {
+ Ok(enums::AttemptStatus::Charged)
+ } else {
+ Ok(enums::AttemptStatus::Authorized)
+ }
+ }
+ TesouroSyncStatus::DeclinedAuthorization => {
+ if is_auto_capture {
+ Ok(enums::AttemptStatus::AuthorizationFailed)
+ } else {
+ Ok(enums::AttemptStatus::Failure)
+ }
+ }
+ TesouroSyncStatus::ApprovedReversal => Ok(enums::AttemptStatus::Voided),
+ TesouroSyncStatus::DeclinedCapture => Ok(enums::AttemptStatus::Failure),
+ TesouroSyncStatus::DeclinedReversal => Ok(enums::AttemptStatus::VoidFailed),
+ TesouroSyncStatus::GenericPaymentTransaction => Ok(previous_status),
+ TesouroSyncStatus::Authorization => Ok(enums::AttemptStatus::Authorizing),
+ TesouroSyncStatus::Capture => Ok(enums::AttemptStatus::CaptureInitiated),
+ TesouroSyncStatus::Reversal => Ok(enums::AttemptStatus::VoidInitiated),
+ TesouroSyncStatus::ApprovedRefund
+ | TesouroSyncStatus::ApprovedRefundAuthorization
+ | TesouroSyncStatus::DeclinedRefund
+ | TesouroSyncStatus::DeclinedRefundAuthorization
+ | TesouroSyncStatus::Refund
+ | TesouroSyncStatus::RefundAuthorization => {
+ Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from("Invalid Status Recieved".to_string()),
+ ))
+ }
+ }
+}
+
+impl TryFrom<&PaymentsSyncRouterData> for TesouroSyncRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PaymentsSyncRouterData) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ query: tesouro_queries::SYNC_TRANSACTION.to_string(),
+ variables: TesouroSyncInput {
+ payment_transaction_id: item
+ .request
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?,
+ },
})
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
-pub struct TesouroErrorResponse {
- pub status_code: u16,
- pub code: String,
- pub message: String,
- pub reason: Option<String>,
- pub network_advice_code: Option<String>,
- pub network_decline_code: Option<String>,
- pub network_error_message: Option<String>,
+impl<F> TryFrom<ResponseRouterData<F, TesouroSyncResponse, PaymentsSyncData, PaymentsResponseData>>
+ for RouterData<F, PaymentsSyncData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, TesouroSyncResponse, PaymentsSyncData, PaymentsResponseData>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ let status = get_payment_attempt_status(
+ response.data.payment_transaction.typename,
+ item.data.request.is_auto_capture()?,
+ item.data.status,
+ )?;
+ if connector_utils::is_payment_failure(status) {
+ let error_code = response
+ .data
+ .payment_transaction
+ .processor_response_code
+ .unwrap_or(NO_ERROR_CODE.to_string());
+
+ let error_message = response
+ .data
+ .payment_transaction
+ .processor_response_message
+ .unwrap_or(NO_ERROR_CODE.to_string());
+
+ let connector_transaction_id = response.data.payment_transaction.id.clone();
+
+ Ok(Self {
+ status,
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message.clone(),
+ reason: Some(error_message.clone()),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: Some(connector_transaction_id),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Ok(Self {
+ status,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
+ response.data.payment_transaction.id.to_string(),
+ ),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ TesouroApiResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ status: item.data.status,
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+impl TryFrom<&RefundSyncRouterData> for TesouroSyncRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &RefundSyncRouterData) -> Result<Self, Self::Error> {
+ Ok(Self {
+ query: tesouro_queries::SYNC_TRANSACTION.to_string(),
+ variables: TesouroSyncInput {
+ payment_transaction_id: item.request.get_connector_refund_id()?,
+ },
+ })
+ }
+}
+
+impl TryFrom<RefundsResponseRouterData<RSync, TesouroSyncResponse>> for RefundsRouterData<RSync> {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: RefundsResponseRouterData<RSync, TesouroSyncResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ TesouroApiResponse::TesouroApiSuccessResponse(response) => {
+ let status = match response.data.payment_transaction.typename {
+ TesouroSyncStatus::ApprovedRefund => enums::RefundStatus::Success,
+ TesouroSyncStatus::DeclinedRefund
+ | TesouroSyncStatus::DeclinedRefundAuthorization => {
+ enums::RefundStatus::Failure
+ }
+ TesouroSyncStatus::GenericPaymentTransaction
+ | TesouroSyncStatus::Refund
+ | TesouroSyncStatus::RefundAuthorization
+ | TesouroSyncStatus::ApprovedRefundAuthorization => {
+ enums::RefundStatus::Pending
+ }
+ _ => {
+ return Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from("Invalid Status Recieved".to_string()),
+ )
+ .into())
+ }
+ };
+
+ if connector_utils::is_refund_failure(status) {
+ let error_code = response
+ .data
+ .payment_transaction
+ .processor_response_code
+ .unwrap_or(NO_ERROR_CODE.to_string());
+
+ let error_message = response
+ .data
+ .payment_transaction
+ .processor_response_message
+ .unwrap_or(NO_ERROR_CODE.to_string());
+
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: error_code.clone(),
+ message: error_message.clone(),
+ reason: Some(error_message.clone()),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: response.data.payment_transaction.id,
+ refund_status: enums::RefundStatus::Success,
+ }),
+ ..item.data
+ })
+ }
+ }
+ TesouroApiResponse::TesouroErrorResponse(error_response) => {
+ let message = error_response
+ .errors
+ .iter()
+ .map(|error| error.message.to_string())
+ .collect::<Vec<String>>();
+
+ let error_message = match !message.is_empty() {
+ true => Some(message.join(" ")),
+ false => None,
+ };
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: error_message
+ .clone()
+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),
+ reason: error_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+fn get_valid_transaction_id(
+ id: String,
+) -> Result<String, error_stack::Report<errors::ConnectorError>> {
+ if id.len() <= tesouro_constants::MAX_PAYMENT_REFERENCE_ID_LENGTH {
+ Ok(id.clone())
+ } else {
+ Err(errors::ConnectorError::MaxFieldLengthViolated {
+ connector: "Tesouro".to_string(),
+ field_name: "transaction_reference".to_string(),
+ max_length: tesouro_constants::MAX_PAYMENT_REFERENCE_ID_LENGTH,
+ received_length: id.len(),
+ }
+ .into())
+ }
}
diff --git a/crates/payment_methods/src/configs/payment_connector_required_fields.rs b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
index 0981d332d9..b9af92239c 100644
--- a/crates/payment_methods/src/configs/payment_connector_required_fields.rs
+++ b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
@@ -1610,6 +1610,19 @@ fn get_cards_required_fields() -> HashMap<Connector, RequiredFieldFinal> {
Connector::Trustpayments,
fields(vec![], vec![], card_basic()),
),
+ (
+ Connector::Tesouro,
+ fields(
+ vec![],
+ vec![],
+ vec![
+ RequiredField::CardNumber,
+ RequiredField::CardExpMonth,
+ RequiredField::CardExpYear,
+ RequiredField::CardCvc,
+ ],
+ ),
+ ),
(Connector::Tsys, fields(vec![], card_basic(), vec![])),
(
Connector::Wellsfargo,
diff --git a/crates/router/src/core/connector_validation.rs b/crates/router/src/core/connector_validation.rs
index 009c3612d8..bcd766b116 100644
--- a/crates/router/src/core/connector_validation.rs
+++ b/crates/router/src/core/connector_validation.rs
@@ -495,6 +495,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
stripebilling::transformers::StripebillingAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_enums::Connector::Tesouro => {
+ tesouro::transformers::TesouroAuthType::try_from(self.auth_type)?;
+ Ok(())
+ }
api_enums::Connector::Trustpay => {
trustpay::transformers::TrustpayAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/types/api/connector_mapping.rs b/crates/router/src/types/api/connector_mapping.rs
index 3cf6ac51a7..5587462df8 100644
--- a/crates/router/src/types/api/connector_mapping.rs
+++ b/crates/router/src/types/api/connector_mapping.rs
@@ -438,6 +438,9 @@ impl ConnectorData {
Ok(ConnectorEnum::Old(Box::new(connector::Paystack::new())))
}
// enums::Connector::Thunes => Ok(ConnectorEnum::Old(Box::new(connector::Thunes))),
+ enums::Connector::Tesouro => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Tesouro::new())))
+ }
enums::Connector::Tokenex => Ok(ConnectorEnum::Old(Box::new(&connector::Tokenex))),
enums::Connector::Tokenio => {
Ok(ConnectorEnum::Old(Box::new(connector::Tokenio::new())))
diff --git a/crates/router/src/types/api/feature_matrix.rs b/crates/router/src/types/api/feature_matrix.rs
index 5063abab7a..20bb99a6bc 100644
--- a/crates/router/src/types/api/feature_matrix.rs
+++ b/crates/router/src/types/api/feature_matrix.rs
@@ -359,6 +359,9 @@ impl FeatureMatrixConnectorData {
Ok(ConnectorEnum::Old(Box::new(connector::Paystack::new())))
}
// enums::Connector::Thunes => Ok(ConnectorEnum::Old(Box::new(connector::Thunes))),
+ enums::Connector::Tesouro => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Tesouro::new())))
+ }
enums::Connector::Tokenex => Ok(ConnectorEnum::Old(Box::new(&connector::Tokenex))),
enums::Connector::Tokenio => {
Ok(ConnectorEnum::Old(Box::new(connector::Tokenio::new())))
diff --git a/crates/router/src/types/connector_transformers.rs b/crates/router/src/types/connector_transformers.rs
index ef7fa0e33d..1455b3a871 100644
--- a/crates/router/src/types/connector_transformers.rs
+++ b/crates/router/src/types/connector_transformers.rs
@@ -147,6 +147,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Stripe => Self::Stripe,
api_enums::Connector::Stripebilling => Self::Stripebilling,
// api_enums::Connector::Thunes => Self::Thunes,
+ api_enums::Connector::Tesouro => Self::Tesouro,
api_enums::Connector::Tokenex => {
Err(common_utils::errors::ValidationError::InvalidValue {
message: "Tokenex is not a routable connector".to_string(),
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Tesouro.js b/cypress-tests/cypress/e2e/configs/Payment/Tesouro.js
new file mode 100644
index 0000000000..175f6c0c40
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payment/Tesouro.js
@@ -0,0 +1,547 @@
+import { customerAcceptance } from "./Commons";
+
+const successfulNo3DSCardDetails = {
+ card_number: "4530910000012345",
+ card_exp_month: "10",
+ card_exp_year: "25",
+ card_holder_name: "John",
+ card_cvc: "111",
+};
+
+const successfulNoThreeDsCardDetailsRequest = {
+ card_number: "4530910000012345",
+ card_exp_month: "10",
+ card_exp_year: "25",
+ card_holder_name: "John",
+ card_cvc: "111",
+};
+
+const successfulThreeDSTestCardDetails = {
+ card_number: "4000000000001091",
+ card_exp_month: "10",
+ card_exp_year: "25",
+ card_holder_name: "Joseph",
+ card_cvc: "111",
+};
+
+const singleUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ single_use: {
+ amount: 8000,
+ currency: "USD",
+ },
+ },
+};
+
+const multiUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ multi_use: {
+ amount: 8000,
+ currency: "USD",
+ },
+ },
+};
+
+export const connectorDetails = {
+ card_pm: {
+ PaymentIntent: {
+ Request: {
+ currency: "USD",
+ amount: 6000,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ amount: 6000,
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ amount: 6000,
+ shipping_cost: 50,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6050,
+ amount: 6000,
+ net_amount: 6050,
+ },
+ },
+ },
+ "3DSManualCapture": {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_16",
+ },
+ },
+ },
+ },
+ // 3DS automatic capture
+ "3DSAutoCapture": {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ amount: 6000,
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_16",
+ },
+ },
+ },
+ },
+ No3DSManualCapture: {
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ No3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ Capture: {
+ Request: {
+ amount_to_capture: 6000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ amount: 6000,
+ amount_capturable: 0,
+ amount_received: 6000,
+ },
+ },
+ },
+ PartialCapture: {
+ Request: {
+ amount_to_capture: 2000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "partially_captured",
+ amount: 6000,
+ amount_capturable: 0,
+ amount_received: 2000,
+ },
+ },
+ },
+ Void: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "cancelled",
+ },
+ },
+ },
+ Refund: {
+ Request: {
+ amount: 6000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ PartialRefund: {
+ Request: {
+ amount: 2000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ manualPaymentRefund: {
+ Request: {
+ amount: 6000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ manualPaymentPartialRefund: {
+ Request: {
+ amount: 2000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ SyncRefund: {
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ ZeroAuthMandate: {
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Setup Mandate flow for Tesouro is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ },
+ ZeroAuthPaymentIntent: {
+ Request: {
+ amount: 0,
+ setup_future_usage: "off_session",
+ currency: "USD",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "off_session",
+ },
+ },
+ },
+ ZeroAuthConfirmPayment: {
+ Request: {
+ payment_type: "setup_mandate",
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Setup Mandate flow for Tesouro is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ setup_future_usage: "on_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ SaveCardUseNo3DSManualCapture: {
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ setup_future_usage: "on_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardUseNo3DSManualCaptureOffSession: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNoThreeDsCardDetailsRequest,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardConfirmManualCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_type: "debit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateSingleUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateMultiUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ MandateMultiUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateSingleUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ MITManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ PaymentIntentOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ currency: "EUR",
+ amount: 6000,
+ authentication_type: "no_three_ds",
+ customer_acceptance: null,
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "off_session",
+ },
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 62d7df0f69..a97d878229 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -56,6 +56,7 @@ import { connectorDetails as squareConnectorDetails } from "./Square.js";
import { connectorDetails as staxConnectorDetails } from "./Stax.js";
import { connectorDetails as stripeConnectorDetails } from "./Stripe.js";
import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js";
+import { connectorDetails as tesouroConnectorDetails } from "./Tesouro.js";
import { connectorDetails as trustpaymentsConnectorDetails } from "./TrustPayments.js";
import { connectorDetails as tsysConnectorDetails } from "./Tsys.js";
import { connectorDetails as wellsfargoConnectorDetails } from "./WellsFargo.js";
@@ -120,6 +121,7 @@ const connectorDetails = {
stax: staxConnectorDetails,
stripe: stripeConnectorDetails,
trustpay: trustpayConnectorDetails,
+ tesouro: tesouroConnectorDetails,
trustpayments: trustpaymentsConnectorDetails,
tsys: tsysConnectorDetails,
wellsfargo: wellsfargoConnectorDetails,