Skip to content

Commit

Permalink
Added destination object inside refund payment request (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Jun 4, 2024
1 parent 43088ec commit 7b3a845
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,18 @@ type (
To *time.Time `url:"to,omitempty" layout:"2006-01-02T15:04:05Z"`
}
)

type (
Destination struct {
AccountType AccountType `json:"account_type,omitempty"`
AccountNumber string `json:"account_number,omitempty"`
BankCode string `json:"bank_code,omitempty"`
BranchCode string `json:"branch_code,omitempty"`
Iban string `json:"iban,omitempty"`
Bban string `json:"bban,omitempty"`
SwiftBic string `json:"swift_bic,omitempty"`
Country Country `json:"country,omitempty"`
AccountHolder *AccountHolder `json:"account_holder,omitempty"`
Bank *BankDetails `json:"bank,omitempty"`
}
)
20 changes: 20 additions & 0 deletions payments/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,23 @@ type (
Address *common.Address `json:"address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
}

Order struct {
Name string `json:"name,omitempty"`
Quantity int64 `json:"quantity,omitempty"`
UnitPrice int64 `json:"unit_price,omitempty"`
Reference string `json:"reference,omitempty"`
CommodityCode string `json:"commodity_code,omitempty"`
UnitOfMeasure string `json:"unit_of_measure,omitempty"`
TotalAmount int64 `json:"total_amount,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
DiscountAmount int64 `json:"discount_amount,omitempty"`
WxpayGoodsId string `json:"wxpay_goods_id,omitempty"`
ImageUrl string `json:"image_url,omitempty"`
Url string `json:"url,omitempty"`
Type string `json:"type,omitempty"`
ServiceEndsOn *time.Time `json:"service_ends_on,omitempty"`
}
)

// Request
Expand All @@ -448,6 +465,9 @@ type (
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Not available on Previous
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
CaptureActionId string `json:"capture_action_id,omitempty"`
Destination *common.Destination `json:"destination,omitempty"`
Items []Order `json:"items,omitempty"`
}

VoidRequest struct {
Expand Down
31 changes: 31 additions & 0 deletions test/payments_refunds_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test

import (
"github.com/checkout/checkout-sdk-go/common"
"github.com/checkout/checkout-sdk-go/payments/nas"
"testing"
"time"
Expand All @@ -14,8 +15,38 @@ import (
func TestRefundCardPayment(t *testing.T) {
paymentResponse := makeCardPayment(t, true, 10)

order := payments.Order{
Name: "OrderTest",
Quantity: 88,
TotalAmount: 99,
}

bank := common.BankDetails{
Name: "Lloyds TSB",
Branch: "Bournemouth",
Address: Address(),
}

destination := common.Destination{
AccountType: common.Savings,
AccountNumber: "13654567455",
BankCode: "23-456",
BranchCode: "6443",
Iban: "HU93116000060000000012345676",
Bban: "3704 0044 0532 0130 00",
SwiftBic: "37040044",
Country: common.GB,
AccountHolder: AccountHolder(),
Bank: &bank,
}

refundRequest := payments.RefundRequest{
Amount: paymentResponse.Amount,
Reference: uuid.New().String(),
Items: []payments.Order{
order,
},
Destination: &destination,
}

cases := []struct {
Expand Down

0 comments on commit 7b3a845

Please sign in to comment.