Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into robert/circleci_ima…
Browse files Browse the repository at this point in the history
…ge_upgrade
  • Loading branch information
rlcooper46 committed Feb 17, 2022
2 parents 94e66e7 + 689a60c commit ac4c464
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 46 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ jobs:
- run:
name: Integration Test
command: |
go test -v \
-coverpkg $(go list ./... | grep -v integration-tests | grep -v testing | tr '\n' ',' | sed -e 's/.$//') \
-coverprofile=integration_coverage.profile ./integration-tests/*.go
cd integration-tests
go test -v
- save_cache:
key: v1-pkg-cache
paths:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ We support abstracting PsP Webhook notifications into a common interface.
| [Authorize.Net](https://developer.authorize.net/api/reference/index.html#payment-transactions) |||
| [Braintree](https://www.braintreepayments.com/) |||
| [CyberSource](https://developer.cybersource.com/api-reference-assets/index.html#payments) |||
| [Checkout.com](https://api-reference.checkout.com/) |||
| [FirstData](https://docs.firstdata.com/org/gateway/docs/api) |||
| [NMI](https://secure.networkmerchants.com/gw/merchants/resources/integration/integration_portal.php#methodology) |||
| [Orbital](https://developer.jpmorgan.com/products/orbital-api) |||
Expand Down
14 changes: 0 additions & 14 deletions coverage.txt

This file was deleted.

5 changes: 0 additions & 5 deletions gateways/checkoutcom/checkoutcom.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package checkoutcom

import (
"encoding/json"
"fmt"
"github.com/BoltApp/sleet"
"github.com/BoltApp/sleet/common"
"github.com/checkout/checkout-sdk-go"
Expand Down Expand Up @@ -63,9 +61,6 @@ func (client *CheckoutComClient) Authorize(request *sleet.AuthorizationRequest)
return &sleet.AuthorizationResponse{Success: false, TransactionReference: "", AvsResult: sleet.AVSResponseUnknown, CvvResult: sleet.CVVResponseUnknown, ErrorCode: err.Error()}, err
}

out, _ := json.Marshal(response.StatusResponse.ResponseBody)
fmt.Printf(string(out))

if *response.Processed.Approved {
return &sleet.AuthorizationResponse{
Success: true,
Expand Down
61 changes: 53 additions & 8 deletions gateways/checkoutcom/request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"github.com/checkout/checkout-sdk-go/payments"
)

// Cof specifies the transaction type under the Credential-on-File framework
const recurringPaymentType = "Recurring"

func buildChargeParams(authRequest *sleet.AuthorizationRequest) (*payments.Request, error) {
var source = payments.CardSource{
Type: "card",
Expand All @@ -25,7 +28,7 @@ func buildChargeParams(authRequest *sleet.AuthorizationRequest) (*payments.Reque
},
}

return &payments.Request{
request := &payments.Request{
Source: source,
Amount: uint64(authRequest.Amount.Amount),
Capture: common.BPtr(false),
Expand All @@ -35,21 +38,63 @@ func buildChargeParams(authRequest *sleet.AuthorizationRequest) (*payments.Reque
Email: common.SafeStr(authRequest.BillingAddress.Email),
Name: authRequest.CreditCard.FirstName + " " + authRequest.CreditCard.LastName,
},
}, nil
}

if authRequest.ProcessingInitiator != nil {
initializeProcessingInitiator(authRequest, request, &source)
}

return request, nil
}

func initializeProcessingInitiator(authRequest *sleet.AuthorizationRequest, request *payments.Request, source *payments.CardSource) {
// see documentation for instructions on stored credentials, merchant-initiated transactions, and subscriptions:
// https://www.checkout.com/docs/four/payments/accept-payments/use-saved-details/about-stored-card-details
switch *authRequest.ProcessingInitiator {
// initiated by merchant or cardholder, stored card, recurring, first payment
case sleet.ProcessingInitiatorTypeInitialRecurring:
if authRequest.CreditCard.Network == sleet.CreditCardNetworkVisa {
request.PaymentType = recurringPaymentType // visa only
}
request.MerchantInitiated = common.BPtr(false)
// initiated by merchant, stored card, recurring/single transaction, follow-on payment
case sleet.ProcessingInitiatorTypeFollowingRecurring,
sleet.ProcessingInitiatorTypeStoredMerchantInitiated:
request.MerchantInitiated = common.BPtr(true)
source.Stored = common.BPtr(true)
request.PaymentType = recurringPaymentType
request.PreviousPaymentID = *authRequest.PreviousExternalTransactionID
// initiated by cardholder, stored card, single transaction, follow-on payment
case sleet.ProcessingInitiatorTypeStoredCardholderInitiated:
source.Stored = common.BPtr(true)
// initiated by merchant or cardholder, stored card, single transaction, first payment
case sleet.ProcessingInitiatorTypeInitialCardOnFile:
request.MerchantInitiated = common.BPtr(false)
}
}

func buildRefundParams(refundRequest *sleet.RefundRequest) (*payments.RefundsRequest, error) {
return &payments.RefundsRequest{
request := &payments.RefundsRequest{
Amount: uint64(refundRequest.Amount.Amount),
Reference: *refundRequest.MerchantOrderReference,
}, nil
}

if refundRequest.MerchantOrderReference != nil {
request.Reference = *refundRequest.MerchantOrderReference
}

return request, nil
}

func buildCaptureParams(captureRequest *sleet.CaptureRequest) (*payments.CapturesRequest, error) {
return &payments.CapturesRequest{
request := &payments.CapturesRequest{
Amount: uint64(captureRequest.Amount.Amount),
Reference: *captureRequest.MerchantOrderReference,
}, nil
}

if captureRequest.MerchantOrderReference != nil {
request.Reference = *captureRequest.MerchantOrderReference
}

return request, nil
}

func buildVoidParams(voidRequest *sleet.VoidRequest) (*payments.VoidsRequest, error) {
Expand Down
9 changes: 5 additions & 4 deletions gateways/nmi/request_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package nmi

import (
"fmt"
"github.com/BoltApp/sleet"
"strconv"

"github.com/BoltApp/sleet"
"github.com/shopspring/decimal"
)

// NMI transaction types
Expand Down Expand Up @@ -85,7 +87,6 @@ func enableTestMode(testMode bool) *string {
}

func formatAmount(amountInt int64) *string {
amountString := strconv.FormatInt(amountInt, 10)
formattedAmount := fmt.Sprintf("%s.%s", amountString[:len(amountString)-2], amountString[len(amountString)-2:])
return &formattedAmount
formattatedAmount := decimal.NewFromInt(amountInt).Div(decimal.NewFromInt(int64(100))).StringFixed(2)
return &formattatedAmount
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/google/go-cmp v0.5.1
github.com/jarcoal/httpmock v1.0.5
github.com/rocketgate/rocketgate-go-sdk v0.0.0-20220106233346-17d98d87a0ff
github.com/shopspring/decimal v1.3.1 // indirect
github.com/stripe/stripe-go v70.11.0+incompatible
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rocketgate/rocketgate-go-sdk v0.0.0-20220106233346-17d98d87a0ff h1:KcXYk9nBcMz35HTctRxrTziAjSJUk1Lid5WVaEMjU6w=
github.com/rocketgate/rocketgate-go-sdk v0.0.0-20220106233346-17d98d87a0ff/go.mod h1:5zfoDg5zWlwcB1SlaOLYa2Hm9YJaQlB7fqccBb6tosg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
12 changes: 0 additions & 12 deletions test.sh

This file was deleted.

0 comments on commit ac4c464

Please sign in to comment.