Skip to content

Commit f4cdcf7

Browse files
authored
Merge pull request #89 from jordancco/response-properties
Added missing RVS Response Fields
2 parents 04b80e5 + ab2fbee commit f4cdcf7

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

amazon/validator.go

+6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ type IAPResponse struct {
3131
ProductType string `json:"productType"`
3232
ProductID string `json:"productId"`
3333
PurchaseDate int64 `json:"purchaseDate"`
34+
RenewalDate int64 `json:"renewalDate"`
3435
CancelDate int64 `json:"cancelDate"`
3536
TestTransaction bool `json:"testTransaction"`
37+
BetaProduct bool `json:"betaProduct"`
38+
ParentProductID string `json:"parentProductId"`
39+
Quantity int64 `json:"quantity"`
40+
Term string `json:"term"`
41+
TermSku string `json:"termSku"`
3642
}
3743

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

amazon/validator_test.go

+33-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,38 @@ func TestNewWithClient(t *testing.T) {
110110
}
111111
}
112112

113-
func TestVerify(t *testing.T) {
113+
func TestVerifySubscription(t *testing.T) {
114+
t.Parallel()
115+
server, client := testTools(
116+
200,
117+
"{\"purchaseDate\":1558424877035,\"receiptId\":\"q1YqVrJSSs7P1UvMTazKz9PLTCwoTswtyEktM9JLrShIzCvOzM-LL04tiTdW0lFKASo2NDEwMjCwMDM2MTC0AIqVAsUsLd1c4l18jIxdfTOK_N1d8kqLLHVLc8oK83OLgtPNCit9AoJdjJ3dXG2BGkqUrAxrAQ\",\"productId\":\"com.amazon.iapsamplev2.expansion_set_3\",\"parentProductId\":null,\"productType\":\"SUBSCRIPTION\",\"renewalDate\":1561103277035,\"quantity\":1,\"betaProduct\":false,\"testTransaction\":true,\"term\":\"1 Week\",\"termSku\":\"sub1-weekly\"}",
118+
)
119+
defer server.Close()
120+
121+
expected := IAPResponse{
122+
ReceiptID: "q1YqVrJSSs7P1UvMTazKz9PLTCwoTswtyEktM9JLrShIzCvOzM-LL04tiTdW0lFKASo2NDEwMjCwMDM2MTC0AIqVAsUsLd1c4l18jIxdfTOK_N1d8kqLLHVLc8oK83OLgtPNCit9AoJdjJ3dXG2BGkqUrAxrAQ",
123+
ProductType: "SUBSCRIPTION",
124+
ProductID: "com.amazon.iapsamplev2.expansion_set_3",
125+
PurchaseDate: 1558424877035,
126+
RenewalDate: 1561103277035,
127+
CancelDate: 0,
128+
TestTransaction: true,
129+
Quantity: 1,
130+
Term: "1 Week",
131+
TermSku: "sub1-weekly",
132+
}
133+
134+
actual, _ := client.Verify(
135+
context.Background(),
136+
"99FD_DL23EMhrOGDnur9-ulvqomrSg6qyLPSD3CFE=",
137+
"q1YqVrJSSs7P1UvMTazKz9PLTCwoTswtyEktM9JLrShIzCvOzM-LL04tiTdW0lFKASo2NDEwMjCwMDM2MTC0AIqVAsUsLd1c4l18jIxdfTOK_N1d8kqLLHVLc8oK83OLgtPNCit9AoJdjJ3dXG2BGkqUrAxrAQ",
138+
)
139+
if !reflect.DeepEqual(actual, expected) {
140+
t.Errorf("got %v\nwant %v", actual, expected)
141+
}
142+
}
143+
144+
func TestVerifyEntitled(t *testing.T) {
114145
t.Parallel()
115146
server, client := testTools(
116147
200,
@@ -125,6 +156,7 @@ func TestVerify(t *testing.T) {
125156
PurchaseDate: 1402008634018,
126157
CancelDate: 0,
127158
TestTransaction: true,
159+
Quantity: 1,
128160
}
129161

130162
actual, _ := client.Verify(

0 commit comments

Comments
 (0)