Skip to content

Commit a5f934d

Browse files
authored
Merge pull request #282 from richzw/master
feat(amazon): add more fields of amazon response
2 parents 1593518 + feb1d2b commit a5f934d

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

amazon/validator.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,26 @@ type Promotion struct {
4747

4848
// The IAPResponse type has the response properties
4949
type IAPResponse struct {
50-
ReceiptID string `json:"receiptId"`
51-
ProductType string `json:"productType"`
52-
ProductID string `json:"productId"`
53-
PurchaseDate int64 `json:"purchaseDate"`
54-
RenewalDate int64 `json:"renewalDate"`
55-
CancelDate int64 `json:"cancelDate"`
56-
TestTransaction bool `json:"testTransaction"`
57-
BetaProduct bool `json:"betaProduct"`
58-
ParentProductID string `json:"parentProductId"`
59-
Quantity int64 `json:"quantity"`
60-
Term string `json:"term"`
61-
TermSku string `json:"termSku"`
62-
FreeTrialEndDate int64 `json:"freeTrialEndDate"`
63-
AutoRenewing bool `json:"autoRenewing"`
64-
CancelReason *int8 `json:"cancelReason"`
65-
GracePeriodEndDate int64 `json:"gracePeriodEndDate"`
66-
Promotions []Promotion `json:"promotions"`
50+
ReceiptID string `json:"receiptId"`
51+
ProductType string `json:"productType"`
52+
ProductID string `json:"productId"`
53+
PurchaseDate int64 `json:"purchaseDate"`
54+
RenewalDate int64 `json:"renewalDate"`
55+
CancelDate int64 `json:"cancelDate"`
56+
TestTransaction bool `json:"testTransaction"`
57+
BetaProduct bool `json:"betaProduct"`
58+
ParentProductID string `json:"parentProductId"`
59+
Quantity int64 `json:"quantity"`
60+
Term string `json:"term"`
61+
TermSku string `json:"termSku"`
62+
FreeTrialEndDate *int64 `json:"freeTrialEndDate"`
63+
AutoRenewing bool `json:"autoRenewing"`
64+
CancelReason *int8 `json:"cancelReason"`
65+
GracePeriodEndDate *int64 `json:"gracePeriodEndDate"`
66+
Promotions []Promotion `json:"promotions"`
67+
FulfillmentDate *int64 `json:"fulfillmentDate"`
68+
FulfillmentResult string `json:"fulfillmentResult"`
69+
PurchaseMetadataMap map[string]string `json:"purchaseMetadataMap"`
6770
}
6871

6972
// The IAPResponseError typs has error message and status.

amazon/validator_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ func TestVerifySubscription(t *testing.T) {
115115
)
116116
defer server.Close()
117117

118+
freeTrialEndDate := int64(1561104377023)
119+
gracePeriodEndDate := int64(1561104377013)
120+
118121
expected := IAPResponse{
119122
ReceiptID: "q1YqVrJSSs7P1UvMTazKz9PLTCwoTswtyEktM9JLrShIzCvOzM-LL04tiTdW0lFKASo2NDEwMjCwMDM2MTC0AIqVAsUsLd1c4l18jIxdfTOK_N1d8kqLLHVLc8oK83OLgtPNCit9AoJdjJ3dXG2BGkqUrAxrAQ",
120123
ProductType: "SUBSCRIPTION",
@@ -126,9 +129,9 @@ func TestVerifySubscription(t *testing.T) {
126129
Quantity: 1,
127130
Term: "1 Week",
128131
TermSku: "sub1-weekly",
129-
FreeTrialEndDate: 1561104377023,
132+
FreeTrialEndDate: &freeTrialEndDate,
130133
AutoRenewing: false,
131-
GracePeriodEndDate: 1561104377013,
134+
GracePeriodEndDate: &gracePeriodEndDate,
132135
}
133136

134137
actual, _ := client.Verify(

0 commit comments

Comments
 (0)