mirror of
https://github.com/plutov/paypal.git
synced 2025-02-02 15:10:36 +01:00
Added GetSubscriptionDetails method (#135)
* Issue #133 Added GetSubscriptionDetails method * Issue #133
This commit is contained in:
parent
8686a619a4
commit
6f0fe4d870
37
subscription.go
Normal file
37
subscription.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package paypal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// SubscriptionDetailResp struct
|
||||||
|
SubscriptionDetailResp struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
PlanID string `json:"plan_id,omitempty"`
|
||||||
|
StartTime time.Time `json:"start_time,omitempty"`
|
||||||
|
Quantity string `json:"quantity,omitempty"`
|
||||||
|
ShippingAmount ShippingAmount `json:"shipping_amount,omitempty"`
|
||||||
|
Subscriber Subscriber `json:"subscriber,omitempty"`
|
||||||
|
BillingInfo BillingInfo `json:"billing_info,omitempty"`
|
||||||
|
CreateTime time.Time `json:"create_time,omitempty"`
|
||||||
|
UpdateTime time.Time `json:"update_time,omitempty"`
|
||||||
|
Links []Link `json:"links,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
StatusUpdateTime time.Time `json:"status_update_time,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetSubscriptionDetails shows details for a subscription, by ID.
|
||||||
|
// Endpoint: GET /v1/billing/subscriptions/
|
||||||
|
func (c *Client) GetSubscriptionDetails(subscriptionID string) (*SubscriptionDetailResp, error) {
|
||||||
|
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v1/billing/subscriptions/%s", c.APIBase, subscriptionID), nil)
|
||||||
|
response := &SubscriptionDetailResp{}
|
||||||
|
if err != nil {
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
err = c.SendWithAuth(req, response)
|
||||||
|
return response, err
|
||||||
|
}
|
37
types.go
37
types.go
|
@ -265,6 +265,15 @@ type (
|
||||||
OverrideMerchantPreferences *MerchantPreferences `json:"override_merchant_preferences,omitempty"`
|
OverrideMerchantPreferences *MerchantPreferences `json:"override_merchant_preferences,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BillingInfo struct
|
||||||
|
BillingInfo struct {
|
||||||
|
OutstandingBalance AmountPayout `json:"outstanding_balance,omitempty"`
|
||||||
|
CycleExecutions []CycleExecutions `json:"cycle_executions,omitempty"`
|
||||||
|
LastPayment LastPayment `json:"last_payment,omitempty"`
|
||||||
|
NextBillingTime time.Time `json:"next_billing_time,omitempty"`
|
||||||
|
FailedPaymentsCount int `json:"failed_payments_count,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// BillingPlan struct
|
// BillingPlan struct
|
||||||
BillingPlan struct {
|
BillingPlan struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
|
@ -359,6 +368,21 @@ type (
|
||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CycleExecutions struct
|
||||||
|
CycleExecutions struct {
|
||||||
|
TenureType string `json:"tenure_type,omitempty"`
|
||||||
|
Sequence int `json:"sequence,omitempty"`
|
||||||
|
CyclesCompleted int `json:"cycles_completed,omitempty"`
|
||||||
|
CyclesRemaining int `json:"cycles_remaining,omitempty"`
|
||||||
|
TotalCycles int `json:"total_cycles,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastPayment struct
|
||||||
|
LastPayment struct {
|
||||||
|
Amount Money `json:"amount,omitempty"`
|
||||||
|
Time time.Time `json:"time,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Details structure used in Amount structures as optional value
|
// Details structure used in Amount structures as optional value
|
||||||
Details struct {
|
Details struct {
|
||||||
Subtotal string `json:"subtotal,omitempty"`
|
Subtotal string `json:"subtotal,omitempty"`
|
||||||
|
@ -778,6 +802,12 @@ type (
|
||||||
SenderBatchID string `json:"sender_batch_id,omitempty"`
|
SenderBatchID string `json:"sender_batch_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ShippingAmount struct
|
||||||
|
ShippingAmount struct {
|
||||||
|
CurrencyCode string `json:"currency_code,omitempty"`
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ShippingAddress struct
|
// ShippingAddress struct
|
||||||
ShippingAddress struct {
|
ShippingAddress struct {
|
||||||
RecipientName string `json:"recipient_name,omitempty"`
|
RecipientName string `json:"recipient_name,omitempty"`
|
||||||
|
@ -812,6 +842,13 @@ type (
|
||||||
Address *ShippingDetailAddressPortable `json:"address,omitempty"`
|
Address *ShippingDetailAddressPortable `json:"address,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subscriber struct
|
||||||
|
Subscriber struct {
|
||||||
|
ShippingAddress ShippingDetail `json:"shipping_address,omitempty"`
|
||||||
|
Name CreateOrderPayerName `json:"name,omitempty"`
|
||||||
|
EmailAddress string `json:"email_address,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
expirationTime int64
|
expirationTime int64
|
||||||
|
|
||||||
// TokenResponse is for API response for the /oauth2/token endpoint
|
// TokenResponse is for API response for the /oauth2/token endpoint
|
||||||
|
|
Loading…
Reference in New Issue
Block a user