Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check payments resources against api reference. #326

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
423 changes: 333 additions & 90 deletions docs/README.md

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions docs/v4-upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Notable changes included in v4

## Breaking changes

- `idempotency` package has moved from the `mollie` directory to the `pkg` directory.
- `pagination` package has moved from the`mollie` directory to the `pkg` directory.
- `connect` package has moved from the `mollie` directory to the `pkg` directory.
- root namespace is not `github.com/VictorAvelar/mollie-api-go/v4/`.
- Changes for payments resource
- Added `CreatePayment` type to use when creating a payment.
- Added `UpdatePayment` type to use when updating a payment.
- Ensured `Payment` object (used for read operations) contains all the available fields.
- Created types specific for fields that are conditional given the payment values, both to create new payments and to list existing payments.

## Other changes

- `testify.Suite` was removed from all testing.
- Improvements for devcontainer files
- Major versions of multiple github actions updated
- Base `Dockerfile` using Go 1.22.x
- Tests related to payments were update to use the new types.
9 changes: 9 additions & 0 deletions mollie/captures.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import (
"time"
)

// CaptureMode describes the mode of a capture.
type CaptureMode string

// CaptureMode possible values.
const (
AutomaticCapture CaptureMode = "automatic"
ManualCapture CaptureMode = "manual"
)

// CapturesService operates over captures resource.
type CapturesService service

Expand Down
10 changes: 10 additions & 0 deletions mollie/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@ const (
TestMode Mode = "test"
)

// IncludeValue is a valid value for the Include query string parameter.
type IncludeValue string

// Supported Include values.
const (
IncludeQrCode IncludeValue = "details.qrCode"
IncludeRemainderDetails IncludeValue = "details.remainderDetails"
)

// EmbedValue describes the valid value of embed query string.
type EmbedValue string

Expand All @@ -330,6 +339,7 @@ const (
EmbedRefund EmbedValue = "refunds"
EmbedShipments EmbedValue = "shipments"
EmbedChargebacks EmbedValue = "chargebacks"
EmbedCaptures EmbedValue = "captures"
)

// Rate describes service rates, further divided into fixed and percentage costs.
Expand Down
2 changes: 1 addition & 1 deletion mollie/customers.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (cs *CustomersService) GetPayments(ctx context.Context, id string, options
// CreatePayment creates a payment for the customer.
//
// See: https://docs.mollie.com/reference/v2/customers-api/create-customer-payment
func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p Payment) (
func (cs *CustomersService) CreatePayment(ctx context.Context, id string, p CreatePayment) (
res *Response,
pp *Payment,
err error,
Expand Down
26 changes: 21 additions & 5 deletions mollie/customers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func TestCustomerService_CreatePayment(t *testing.T) {
type args struct {
ctx context.Context
customer string
payment Payment
payment CreatePayment
}

cases := []struct {
Expand All @@ -637,7 +637,11 @@ func TestCustomerService_CreatePayment(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
Payment{TestMode: true},
CreatePayment{
CreatePaymentAccessTokenFields: CreatePaymentAccessTokenFields{
Testmode: true,
},
},
},
false,
nil,
Expand All @@ -657,7 +661,11 @@ func TestCustomerService_CreatePayment(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
Payment{TestMode: true},
CreatePayment{
CreatePaymentAccessTokenFields: CreatePaymentAccessTokenFields{
Testmode: true,
},
},
},
true,
fmt.Errorf("500 Internal Server Error: An internal server error occurred while processing your request."),
Expand All @@ -669,7 +677,11 @@ func TestCustomerService_CreatePayment(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
Payment{TestMode: true},
CreatePayment{
CreatePaymentAccessTokenFields: CreatePaymentAccessTokenFields{
Testmode: true,
},
},
},
true,
fmt.Errorf("invalid character 'h' looking for beginning of object key string"),
Expand All @@ -681,7 +693,11 @@ func TestCustomerService_CreatePayment(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
Payment{TestMode: true},
CreatePayment{
CreatePaymentAccessTokenFields: CreatePaymentAccessTokenFields{
Testmode: true,
},
},
},
true,
errBadBaseURL,
Expand Down
Loading
Loading