Skip to content

Commit

Permalink
chore(3ds): POINT-1120 add 3DS fields to create transaction request
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-pazdziurek-cko committed Sep 22, 2023
1 parent 7c68ea8 commit f648bad
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 16 deletions.
1 change: 1 addition & 0 deletions settlement_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
cardToUse = "Discover"
)

// FIXME: flaky test - fails every once in a while when run with other tests, succeeds every time when run separately
func TestSettlementBatch(t *testing.T) {
// Get current batch summary
y, m, d := time.Now().Date()
Expand Down
41 changes: 25 additions & 16 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ type Transaction struct {
Status string `xml:"status,omitempty"`
StatusHistory *StatusHistory `xml:"status-history,omitempty"`

Type string `xml:"type,omitempty"`
Amount *Decimal `xml:"amount"`
CurrencyISOCode string `xml:"currency-iso-code,omitempty"`
Tax *Decimal `xml:"tax-amount"`
OrderId string `xml:"order-id,omitempty"`
PaymentMethodToken string `xml:"payment-method-token,omitempty"`
PaymentMethodNonce string `xml:"payment-method-nonce,omitempty"`
MerchantAccountId string `xml:"merchant-account-id,omitempty"`
PlanId string `xml:"plan-id,omitempty"`
CreditCard *CreditCard `xml:"credit-card,omitempty"`
Customer *Customer `xml:"customer,omitempty"`
BillingAddress *Address `xml:"billing,omitempty"`
ShippingAddress *Address `xml:"shipping,omitempty"`
Options *TransactionOptions `xml:"options,omitempty"`
ExternalVault *ExternalVault `xml:"external-vault,omitempty"`
FeeAmount *Decimal `xml:"transaction-fee-amount"`
Type string `xml:"type,omitempty"`
Amount *Decimal `xml:"amount"`
CurrencyISOCode string `xml:"currency-iso-code,omitempty"`
Tax *Decimal `xml:"tax-amount"`
OrderId string `xml:"order-id,omitempty"`
PaymentMethodToken string `xml:"payment-method-token,omitempty"`
PaymentMethodNonce string `xml:"payment-method-nonce,omitempty"`
MerchantAccountId string `xml:"merchant-account-id,omitempty"`
PlanId string `xml:"plan-id,omitempty"`
CreditCard *CreditCard `xml:"credit-card,omitempty"`
Customer *Customer `xml:"customer,omitempty"`
BillingAddress *Address `xml:"billing,omitempty"`
ShippingAddress *Address `xml:"shipping,omitempty"`
Options *TransactionOptions `xml:"options,omitempty"`
ThreeDSecurePassThru *ThreeDSecurePassThrough `xml:"three-d-secure-pass-thru,omitempty"`
ExternalVault *ExternalVault `xml:"external-vault,omitempty"`
FeeAmount *Decimal `xml:"transaction-fee-amount"`

ServiceFeeAmount *Decimal `xml:"service-fee-amount,omitempty"`
ServiceFeeTransaction string `xml:"transaction-fee-currency-iso-code,omitempty"`
Expand Down Expand Up @@ -156,6 +157,14 @@ type TransactionOptions struct {
SkipCVV bool `xml:"skip-cvv,omitempty"`
}

type ThreeDSecurePassThrough struct {
CAVV string `xml:"cavv"`
DSTransactionID string `xml:"ds-transaction-id"`
ECIFlag string `xml:"eci-flag"`
ThreeDSecureVersion string `xml:"three-d-secure-version"`
XID string `xml:"xid"`
}

type TransactionSearchResult struct {
XMLName string `xml:"search-results"`
PageSize *nullable.NullInt64 `xml:"page-size"`
Expand Down
58 changes: 58 additions & 0 deletions transaction_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,64 @@ func TestTransactionCreateSubmitForSettlementAndVoid(t *testing.T) {
}
}

func TestExternal3DSTransactionCreateSubmitForSettlementAndVoid(t *testing.T) {
tx, err := testGateway.Transaction().Create(&Transaction{
Type: "sale",
Amount: NewDecimal(2000, 2),
CreditCard: &CreditCard{
Number: testCreditCards["visa"].Number,
ExpirationDate: "05/14",
},
ThreeDSecurePassThru: &ThreeDSecurePassThrough{
CAVV: "200",
DSTransactionID: "",
ECIFlag: "02",
ThreeDSecureVersion: "1.0.2",
XID: "123",
},
})

t.Log(tx)

if err != nil {
t.Fatal(err)
}
if tx.Id == "" {
t.Fatal("Received invalid ID on new transaction")
}
if tx.Status != "authorized" {
t.Fatal(tx.Status)
}

// Submit for settlement
ten := NewDecimal(1000, 2)
tx2, err := testGateway.Transaction().SubmitForSettlement(tx.Id, ten)

t.Log(tx2)

if err != nil {
t.Fatal(err)
}
if x := tx2.Status; x != "submitted_for_settlement" {
t.Fatal(x)
}
if amount := tx2.Amount; amount.Cmp(ten) != 0 {
t.Fatalf("transaction settlement amount (%s) did not equal amount requested (%s)", amount, ten)
}

// Void
tx3, err := testGateway.Transaction().Void(tx2.Id)

t.Log(tx3)

if err != nil {
t.Fatal(err)
}
if x := tx3.Status; x != "voided" {
t.Fatal(x)
}
}

func TestTransactionSearch(t *testing.T) {
txg := testGateway.Transaction()
createTx := func(amount *Decimal, customerName string) error {
Expand Down

0 comments on commit f648bad

Please sign in to comment.