mirror of
https://github.com/plutov/paypal.git
synced 2025-01-23 02:11:02 +01:00
Order should include payments & purchase_units (#179)
* Order should include purchase_units * PayerWithNameAndPhone needs Address for Order * add SellerProtection to CaptureAmount * add RecipientType(s) * add RecipientType(s) * BatchHeader.BatchStatus values
This commit is contained in:
parent
13112c66e5
commit
476102bb76
30
const.go
30
const.go
|
@ -11,7 +11,7 @@ const (
|
|||
type BillingPlanStatus string
|
||||
|
||||
const (
|
||||
BillingPlanStatusActive BillingPlanStatus = "ACTIVE"
|
||||
BillingPlanStatusActive BillingPlanStatus = "ACTIVE"
|
||||
)
|
||||
|
||||
type IntervalUnit string
|
||||
|
@ -65,6 +65,7 @@ const (
|
|||
|
||||
//Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#definition-transaction
|
||||
type SubscriptionTransactionStatus string
|
||||
|
||||
const (
|
||||
SubscriptionCaptureStatusCompleted SubscriptionTransactionStatus = "COMPLETED"
|
||||
SubscriptionCaptureStatusDeclined SubscriptionTransactionStatus = "DECLINED"
|
||||
|
@ -74,11 +75,12 @@ const (
|
|||
)
|
||||
|
||||
type CaptureType string
|
||||
|
||||
const (
|
||||
CaptureTypeOutstandingBalance CaptureType = "OUTSTANDING_BALANCE"
|
||||
)
|
||||
|
||||
type ProductType string
|
||||
type ProductType string
|
||||
type ProductCategory string //Doc: https://developer.paypal.com/docs/api/catalog-products/v1/#definition-product_category
|
||||
const (
|
||||
ProductTypePhysical ProductType = "PHYSICAL"
|
||||
|
@ -87,15 +89,15 @@ const (
|
|||
|
||||
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"
|
||||
)
|
||||
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"
|
||||
)
|
||||
|
|
|
@ -28,7 +28,7 @@ func ExampleClient_CreateSinglePayout_Venmo() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
// Set payout item with Venmo wallet
|
||||
payout := paypal.Payout{
|
||||
SenderBatchHeader: &paypal.SenderBatchHeader{
|
||||
|
@ -38,9 +38,9 @@ func ExampleClient_CreateSinglePayout_Venmo() {
|
|||
},
|
||||
Items: []paypal.PayoutItem{
|
||||
{
|
||||
RecipientType: "EMAIL",
|
||||
RecipientType: "EMAIL",
|
||||
RecipientWallet: paypal.VenmoRecipientWallet,
|
||||
Receiver: "receiver@example.com",
|
||||
Receiver: "receiver@example.com",
|
||||
Amount: &paypal.AmountPayout{
|
||||
Value: "9.87",
|
||||
Currency: "USD",
|
||||
|
@ -52,4 +52,4 @@ func ExampleClient_CreateSinglePayout_Venmo() {
|
|||
}
|
||||
|
||||
c.CreateSinglePayout(payout)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ var testSecret = "EBoIiUSkCKeSk49hHSgTem1qnjzzJgRQHDEHvGpzlLEf_nIoJd91xu8rPOBDCd
|
|||
var testUserID = "https://www.paypal.com/webapps/auth/identity/user/VBqgHcgZwb1PBs69ybjjXfIW86_Hr93aBvF_Rgbh2II"
|
||||
var testCardID = "CARD-54E6956910402550WKGRL6EA"
|
||||
|
||||
var testProductId = "" // will be fetched in func TestProduct(t *testing.T)
|
||||
var testProductId = "" // will be fetched in func TestProduct(t *testing.T)
|
||||
var testBillingPlan = "" // will be fetched in func TestSubscriptionPlans(t *testing.T)
|
||||
|
||||
func TestGetAccessToken(t *testing.T) {
|
||||
|
@ -386,7 +386,7 @@ func TestSubscription(t *testing.T) {
|
|||
c.GetAccessToken()
|
||||
|
||||
newSubscription := SubscriptionBase{
|
||||
PlanID: testBillingPlan,
|
||||
PlanID: testBillingPlan,
|
||||
}
|
||||
|
||||
//create new subscription
|
||||
|
|
|
@ -57,8 +57,6 @@ func (self *Product) GetUpdatePatch() []Patch {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CreateProduct creates a product
|
||||
// Doc: https://developer.paypal.com/docs/api/catalog-products/v1/#products_create
|
||||
// Endpoint: POST /v1/catalogs/products
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
|
||||
type (
|
||||
SubscriptionBase struct {
|
||||
PlanID string `json:"plan_id"`
|
||||
StartTime *JSONTime `json:"start_time,omitempty"`
|
||||
Quantity string `json:"quantity,omitempty"`
|
||||
PlanID string `json:"plan_id"`
|
||||
StartTime *JSONTime `json:"start_time,omitempty"`
|
||||
Quantity string `json:"quantity,omitempty"`
|
||||
ShippingAmount *Money `json:"shipping_amount,omitempty"`
|
||||
Subscriber *Subscriber `json:"subscriber,omitempty"`
|
||||
AutoRenewal bool `json:"auto_renewal,omitempty"`
|
||||
AutoRenewal bool `json:"auto_renewal,omitempty"`
|
||||
ApplicationContext *ApplicationContext `json:"application_context,omitempty"`
|
||||
CustomID string `json:"custom_id,omitempty"`
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ type (
|
|||
}
|
||||
|
||||
CaptureReqeust struct {
|
||||
Note string `json:"note"`
|
||||
Note string `json:"note"`
|
||||
CaptureType CaptureType `json:"capture_type"`
|
||||
Amount Money `json:"amount"`
|
||||
Amount Money `json:"amount"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -126,7 +126,7 @@ func (c *Client) GetSubscriptionDetails(subscriptionID string) (*SubscriptionDet
|
|||
// Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate
|
||||
// Endpoint: POST /v1/billing/subscriptions/{id}/activate
|
||||
func (c *Client) ActivateSubscription(subscriptionId, activateReason string) error {
|
||||
req, err := c.NewRequest(http.MethodPost, fmt.Sprintf("%s/v1/billing/subscriptions/%s/activate", c.APIBase, subscriptionId), map[string]string{"reason":activateReason})
|
||||
req, err := c.NewRequest(http.MethodPost, fmt.Sprintf("%s/v1/billing/subscriptions/%s/activate", c.APIBase, subscriptionId), map[string]string{"reason": activateReason})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ type (
|
|||
Description string `json:"description,omitempty"`
|
||||
BillingCycles []BillingCycle `json:"billing_cycles"`
|
||||
PaymentPreferences *PaymentPreferences `json:"payment_preferences"`
|
||||
Taxes *Taxes `json:"taxes"`
|
||||
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.
|
||||
}
|
||||
|
||||
|
|
33
types.go
33
types.go
|
@ -116,12 +116,31 @@ const (
|
|||
FeatureUpdateCustomerDispute string = "UPDATE_CUSTOMER_DISPUTES"
|
||||
)
|
||||
|
||||
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/?mark=recipient_type#definition-recipient_type
|
||||
const (
|
||||
EmailRecipientType string = "EMAIL" // An unencrypted email — string of up to 127 single-byte characters.
|
||||
PaypalIdRecipientType string = "PAYPAL_ID" // An encrypted PayPal account number.
|
||||
PhoneRecipientType string = "PHONE" // An unencrypted phone number.
|
||||
// Note: The PayPal sandbox doesn't support type PHONE
|
||||
)
|
||||
|
||||
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/?mark=recipient_wallet#definition-recipient_wallet
|
||||
const (
|
||||
PaypalRecipientWallet string = "PAYPAL"
|
||||
VenmoRecipientWallet string = "VENMO"
|
||||
)
|
||||
|
||||
// Possible value for `batch_status` in GetPayout
|
||||
//
|
||||
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#definition-batch_status
|
||||
const (
|
||||
BatchStatusDenied string = "DENIED"
|
||||
BatchStatusPending string = "PENDING"
|
||||
BatchStatusProcessing string = "PROCESSING"
|
||||
BatchStatusSuccess string = "SUCCESS"
|
||||
BatchStatusCanceled string = "CANCELED"
|
||||
)
|
||||
|
||||
const (
|
||||
LinkRelSelf string = "self"
|
||||
LinkRelActionURL string = "action_url"
|
||||
|
@ -138,10 +157,10 @@ type (
|
|||
|
||||
// Address struct
|
||||
Address struct {
|
||||
Line1 string `json:"line1"`
|
||||
Line1 string `json:"line1,omitempty"`
|
||||
Line2 string `json:"line2,omitempty"`
|
||||
City string `json:"city"`
|
||||
CountryCode string `json:"country_code"`
|
||||
City string `json:"city,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
PostalCode string `json:"postal_code,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
|
@ -520,6 +539,7 @@ type (
|
|||
PurchaseUnit struct {
|
||||
ReferenceID string `json:"reference_id"`
|
||||
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
|
||||
Payments *CapturedPayments `json:"payments,omitempty"`
|
||||
}
|
||||
|
||||
// TaxInfo used for orders.
|
||||
|
@ -610,12 +630,13 @@ type (
|
|||
ExchangeRate *ExchangeRate `json:"exchange_rate,omitempty"`
|
||||
PlatformFees []PlatformFee `json:"platform_fees,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
// CaptureAmount struct
|
||||
CaptureAmount struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
CustomID string `json:"custom_id,omitempty"`
|
||||
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
|
||||
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
|
||||
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
|
||||
SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -650,6 +671,7 @@ type (
|
|||
EmailAddress string `json:"email_address,omitempty"`
|
||||
Phone *PhoneWithType `json:"phone,omitempty"`
|
||||
PayerID string `json:"payer_id,omitempty"`
|
||||
Address Address `json:"address,omitempty"`
|
||||
}
|
||||
|
||||
// CaptureOrderResponse is the response for capture order
|
||||
|
@ -657,6 +679,7 @@ type (
|
|||
ID string `json:"id,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
|
||||
Address *Address `json:"address,omitempty"`
|
||||
PurchaseUnits []CapturedPurchaseUnit `json:"purchase_units,omitempty"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user