Skip to content

Commit

Permalink
Merge pull request #282 from richzw/master
Browse files Browse the repository at this point in the history
feat(amazon): add more fields of amazon response
  • Loading branch information
takecy authored May 23, 2024
2 parents 1593518 + feb1d2b commit a5f934d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
37 changes: 20 additions & 17 deletions amazon/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,26 @@ type Promotion struct {

// The IAPResponse type has the response properties
type IAPResponse struct {
ReceiptID string `json:"receiptId"`
ProductType string `json:"productType"`
ProductID string `json:"productId"`
PurchaseDate int64 `json:"purchaseDate"`
RenewalDate int64 `json:"renewalDate"`
CancelDate int64 `json:"cancelDate"`
TestTransaction bool `json:"testTransaction"`
BetaProduct bool `json:"betaProduct"`
ParentProductID string `json:"parentProductId"`
Quantity int64 `json:"quantity"`
Term string `json:"term"`
TermSku string `json:"termSku"`
FreeTrialEndDate int64 `json:"freeTrialEndDate"`
AutoRenewing bool `json:"autoRenewing"`
CancelReason *int8 `json:"cancelReason"`
GracePeriodEndDate int64 `json:"gracePeriodEndDate"`
Promotions []Promotion `json:"promotions"`
ReceiptID string `json:"receiptId"`
ProductType string `json:"productType"`
ProductID string `json:"productId"`
PurchaseDate int64 `json:"purchaseDate"`
RenewalDate int64 `json:"renewalDate"`
CancelDate int64 `json:"cancelDate"`
TestTransaction bool `json:"testTransaction"`
BetaProduct bool `json:"betaProduct"`
ParentProductID string `json:"parentProductId"`
Quantity int64 `json:"quantity"`
Term string `json:"term"`
TermSku string `json:"termSku"`
FreeTrialEndDate *int64 `json:"freeTrialEndDate"`
AutoRenewing bool `json:"autoRenewing"`
CancelReason *int8 `json:"cancelReason"`
GracePeriodEndDate *int64 `json:"gracePeriodEndDate"`
Promotions []Promotion `json:"promotions"`
FulfillmentDate *int64 `json:"fulfillmentDate"`
FulfillmentResult string `json:"fulfillmentResult"`
PurchaseMetadataMap map[string]string `json:"purchaseMetadataMap"`
}

// The IAPResponseError typs has error message and status.
Expand Down
7 changes: 5 additions & 2 deletions amazon/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ func TestVerifySubscription(t *testing.T) {
)
defer server.Close()

freeTrialEndDate := int64(1561104377023)
gracePeriodEndDate := int64(1561104377013)

expected := IAPResponse{
ReceiptID: "q1YqVrJSSs7P1UvMTazKz9PLTCwoTswtyEktM9JLrShIzCvOzM-LL04tiTdW0lFKASo2NDEwMjCwMDM2MTC0AIqVAsUsLd1c4l18jIxdfTOK_N1d8kqLLHVLc8oK83OLgtPNCit9AoJdjJ3dXG2BGkqUrAxrAQ",
ProductType: "SUBSCRIPTION",
Expand All @@ -126,9 +129,9 @@ func TestVerifySubscription(t *testing.T) {
Quantity: 1,
Term: "1 Week",
TermSku: "sub1-weekly",
FreeTrialEndDate: 1561104377023,
FreeTrialEndDate: &freeTrialEndDate,
AutoRenewing: false,
GracePeriodEndDate: 1561104377013,
GracePeriodEndDate: &gracePeriodEndDate,
}

actual, _ := client.Verify(
Expand Down

0 comments on commit a5f934d

Please sign in to comment.