mirror of
https://github.com/plutov/paypal.git
synced 2025-01-23 02:11:02 +01:00
Fixed incorrect response type in ListSubscriptionPlans (#153)
* Update billing plan * Update billing plan * Update billing plan * Kickstart product creation * Added product api * Added list product api and refactored some similar structs * Reverted endpoint for old billing plans * Added subscription plans create get update list * Added subscription plans activate/deactivate/update pricing scheme * Added integration tests for subscription plans * go fmt * Add subscriptions API * Removed AWS library added by mistake * reverted billing plans url * resolved MR discussions * Fixed but in listing subscription plans, and some constants * Fixed wrong type for subscription plan description * Fixed updating issue Co-authored-by: rami <admin@okitoo.net>
This commit is contained in:
parent
d355a65df0
commit
0461b35d07
22
const.go
22
const.go
|
@ -76,4 +76,26 @@ const (
|
|||
type CaptureType string
|
||||
const (
|
||||
CaptureTypeOutstandingBalance CaptureType = "OUTSTANDING_BALANCE"
|
||||
)
|
||||
|
||||
type ProductType string
|
||||
type ProductCategory string //Doc: https://developer.paypal.com/docs/api/catalog-products/v1/#definition-product_category
|
||||
const (
|
||||
ProductTypePhysical ProductType = "PHYSICAL"
|
||||
ProductTypeDigital ProductType = "DIGITAL"
|
||||
ProductTypeService ProductType = "SERVICE"
|
||||
|
||||
ProductCategorySoftware ProductCategory = "SOFTWARE"
|
||||
ProductCategorySoftwareComputerAndDataProcessingServices ProductCategory = "COMPUTER_AND_DATA_PROCESSING_SERVICES"
|
||||
ProductCategorySoftwareDigitalGames ProductCategory = "DIGITAL_GAMES"
|
||||
ProductCategorySoftwareGameSoftware ProductCategory = "GAME_SOFTWARE"
|
||||
ProductCategorySoftwareGames ProductCategory = "GAMES"
|
||||
ProductCategorySoftwareGeneral ProductCategory = "GENERAL"
|
||||
ProductCategorySoftwareGraphicAndCommercialDesign ProductCategory = "GRAPHIC_AND_COMMERCIAL_DESIGN"
|
||||
ProductCategorySoftwareOemSoftware ProductCategory = "OEM_SOFTWARE"
|
||||
ProductCategorySoftwareOnlineGaming ProductCategory = "ONLINE_GAMING"
|
||||
ProductCategorySoftwareOnlineGamingCurrency ProductCategory = "ONLINE_GAMING_CURRENCY"
|
||||
ProductCategorySoftwareOnlineServices ProductCategory = "ONLINE_SERVICES"
|
||||
ProductCategorySoftwareOther ProductCategory = "OTHER"
|
||||
ProductCategorySoftwareServices ProductCategory = "SERVICES"
|
||||
)
|
|
@ -226,8 +226,8 @@ func TestProduct(t *testing.T) {
|
|||
productData := Product{
|
||||
Name: "Test Product",
|
||||
Description: "A Test Product",
|
||||
Category: PRODUCT_CATEGORY_SOFTWARE,
|
||||
Type: PRODUCT_TYPE_SERVICE,
|
||||
Category: ProductCategorySoftware,
|
||||
Type: ProductTypeService,
|
||||
ImageUrl: "https://example.com/image.png",
|
||||
HomeUrl: "https://example.com",
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
ProductType string
|
||||
ProductCategory string
|
||||
|
||||
// Product struct
|
||||
Product struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
|
@ -60,13 +57,7 @@ func (self *Product) GetUpdatePatch() []Patch {
|
|||
}
|
||||
}
|
||||
|
||||
const (
|
||||
PRODUCT_TYPE_PHYSICAL ProductType = "PHYSICAL"
|
||||
PRODUCT_TYPE_DIGITAL ProductType = "DIGITAL"
|
||||
PRODUCT_TYPE_SERVICE ProductType = "SERVICE"
|
||||
|
||||
PRODUCT_CATEGORY_SOFTWARE ProductCategory = "software"
|
||||
)
|
||||
|
||||
// CreateProduct creates a product
|
||||
// Doc: https://developer.paypal.com/docs/api/catalog-products/v1/#products_create
|
||||
|
|
|
@ -13,10 +13,10 @@ type (
|
|||
ProductId string `json:"product_id"`
|
||||
Name string `json:"name"`
|
||||
Status SubscriptionPlanStatus `json:"status"`
|
||||
Description SubscriptionPlanStatus `json:"description,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
BillingCycles []BillingCycle `json:"billing_cycles"`
|
||||
PaymentPreferences PaymentPreferences `json:"payment_preferences"`
|
||||
Taxes Taxes `json:"taxes"`
|
||||
PaymentPreferences *PaymentPreferences `json:"payment_preferences"`
|
||||
Taxes *Taxes `json:"taxes"`
|
||||
QuantitySupported bool `json:"quantity_supported"` //Indicates whether you can subscribe to this plan by providing a quantity for the goods or service.
|
||||
}
|
||||
|
||||
|
@ -88,35 +88,41 @@ func (self *SubscriptionPlan) GetUpdatePatch() []Patch {
|
|||
Path: "/description",
|
||||
Value: self.Description,
|
||||
},
|
||||
{
|
||||
}
|
||||
|
||||
if self.Taxes != nil {
|
||||
result = append(result, Patch{
|
||||
Operation: "replace",
|
||||
Path: "/taxes/percentage",
|
||||
Value: self.Taxes.Percentage,
|
||||
})
|
||||
}
|
||||
|
||||
if self.PaymentPreferences != nil {
|
||||
if self.PaymentPreferences.SetupFee != nil {
|
||||
result = append(result, Patch{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/setup_fee",
|
||||
Value: self.PaymentPreferences.SetupFee,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
result = append(result, []Patch{{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/auto_bill_outstanding",
|
||||
Value: self.PaymentPreferences.AutoBillOutstanding,
|
||||
},
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/payment_failure_threshold",
|
||||
Value: self.PaymentPreferences.PaymentFailureThreshold,
|
||||
},
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/setup_fee_failure_action",
|
||||
Value: self.PaymentPreferences.SetupFeeFailureAction,
|
||||
},
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/taxes/percentage",
|
||||
Value: self.Taxes.Percentage,
|
||||
},
|
||||
}
|
||||
|
||||
if self.PaymentPreferences.SetupFee != nil {
|
||||
result = append(result, Patch{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/setup_fee",
|
||||
Value: self.PaymentPreferences.SetupFee,
|
||||
},
|
||||
)
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/payment_failure_threshold",
|
||||
Value: self.PaymentPreferences.PaymentFailureThreshold,
|
||||
},
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/payment_preferences/setup_fee_failure_action",
|
||||
Value: self.PaymentPreferences.SetupFeeFailureAction,
|
||||
}}...)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -163,9 +169,9 @@ func (c *Client) GetSubscriptionPlan(planId string) (*SubscriptionPlan, error) {
|
|||
// List all plans
|
||||
// Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_list
|
||||
// Endpoint: GET /v1/billing/plans
|
||||
func (c *Client) ListSubscriptionPlans(params *SubscriptionPlanListParameters) (*ListProductsResponse, error) {
|
||||
func (c *Client) ListSubscriptionPlans(params *SubscriptionPlanListParameters) (*ListSubscriptionPlansResponse, error) {
|
||||
req, err := c.NewRequest(http.MethodGet, fmt.Sprintf("%s%s", c.APIBase, "/v1/billing/plans"), nil)
|
||||
response := &ListProductsResponse{}
|
||||
response := &ListSubscriptionPlansResponse{}
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user