-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
149 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package payment | ||
|
||
import ( | ||
"context" | ||
"github.com/go-faster/errors" | ||
"wss-payment/pkg/util" | ||
) | ||
|
||
// ServiceMock is a mock for a payment service | ||
type ServiceMock struct { | ||
FailCreation bool | ||
FailVerification bool | ||
PaymentVerificationOk bool | ||
} | ||
|
||
func (service ServiceMock) CreateTransaction(context.Context, TransactionCreationRequest) (TransactionCreationResult, error) { | ||
if service.FailCreation { | ||
return TransactionCreationResult{}, errors.New("mock failed!") | ||
} | ||
id := util.RandomID() | ||
return TransactionCreationResult{ | ||
ServiceOrderID: id, | ||
RedirectLink: "https://example.com/" + id, | ||
}, nil | ||
|
||
} | ||
|
||
// VerifyTransaction will verify a previously made transaction and report errors if there was a problem with it | ||
func (service ServiceMock) VerifyTransaction(context.Context, TransactionVerificationRequest) (TransactionVerificationResult, error) { | ||
if service.FailVerification { | ||
return TransactionVerificationResult{}, errors.New("mock failed!") | ||
} | ||
return TransactionVerificationResult{ | ||
TrackID: util.RandomID(), | ||
PaymentOK: service.PaymentVerificationOk, | ||
}, nil | ||
} |
Oops, something went wrong.