Skip to content

Commit

Permalink
Merge branch 'master' into bank-account-tracking-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Alican Akkus committed Nov 9, 2023
2 parents 020deb7 + 4362e26 commit 08637f8
Show file tree
Hide file tree
Showing 18 changed files with 1,100 additions and 560 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://api.c
request := craftgate.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.TRY,
Currency: craftgate.Currency_TRY,
}

res, err := client.Installment.SearchInstallments(context.Background(), request)
Expand Down Expand Up @@ -61,7 +61,7 @@ client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://sandb
request := craftgate.CreatePaymentRequest{
Price: 100,
PaidPrice: 100,
Currency: craftgate.TRY,
Currency: craftgate.Currency_TRY,
...
}

Expand Down
4 changes: 3 additions & 1 deletion adapter/craftgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type Client struct {
FileReporting *FileReporting
Fraud *Fraud
Hook *Hook
Masterpass *Masterpass
BankAccountTracking *BankAccountTracking
}

Expand All @@ -109,15 +110,16 @@ func newClient(apiKey, secretKey string) *Client {

client.Installment = &Installment{Client: client}
client.Payment = &Payment{Client: client}
client.Onboarding = &Onboarding{Client: client}
client.PaymentReporting = &PaymentReporting{Client: client}
client.Onboarding = &Onboarding{Client: client}
client.PayByLink = &PayByLink{Client: client}
client.Wallet = &Wallet{Client: client}
client.Settlement = &Settlement{Client: client}
client.SettlementReporting = &SettlementReporting{Client: client}
client.FileReporting = &FileReporting{Client: client}
client.Fraud = &Fraud{Client: client}
client.Hook = &Hook{Client: client}
client.Masterpass = &Masterpass{Client: client}
client.BankAccountTracking = &BankAccountTracking{Client: client}

return client
Expand Down
85 changes: 85 additions & 0 deletions adapter/masterpass.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package adapter

import (
"context"
"net/http"
)

type Masterpass struct {
Client *Client
}

func (api *Masterpass) CheckMasterpassUser(ctx context.Context, request CheckMasterpassUserRequest) (*CheckMasterpassUserResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "payment/v1/masterpass-payments/check-user", request)
if err != nil {
return nil, err
}

response := &Response[CheckMasterpassUserResponse]{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return nil, err
}

return response.Data, nil
}

func (api *Masterpass) GenerateMasterpassPaymentToken(ctx context.Context, request MasterpassPaymentTokenGenerateRequest) (*MasterpassPaymentTokenGenerateResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "payment/v2/masterpass-payments/generate-token", request)
if err != nil {
return nil, err
}

response := &Response[MasterpassPaymentTokenGenerateResponse]{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return nil, err
}

return response.Data, nil
}

func (api *Masterpass) CompleteMasterpassPayment(ctx context.Context, request MasterpassPaymentCompleteRequest) (*PaymentResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "payment/v2/masterpass-payments/complete", request)
if err != nil {
return nil, err
}

response := &Response[PaymentResponse]{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return nil, err
}

return response.Data, nil
}

func (api *Masterpass) Init3DSMasterpassPayment(ctx context.Context, request MasterpassPaymentThreeDSInitRequest) (*MasterpassPaymentThreeDSInitResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "payment/v2/masterpass-payments/3ds-init", request)
if err != nil {
return nil, err
}

response := &Response[MasterpassPaymentThreeDSInitResponse]{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return nil, err
}

return response.Data, nil
}

func (api *Masterpass) Complete3DSMasterpassPayment(ctx context.Context, request MasterpassPaymentThreeDSCompleteRequest) (*PaymentResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "payment/v2/masterpass-payments/3ds-complete", request)
if err != nil {
return nil, err
}

response := &Response[PaymentResponse]{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return nil, err
}

return response.Data, nil
}
Loading

0 comments on commit 08637f8

Please sign in to comment.