mirror of
https://github.com/plutov/paypal.git
synced 2025-02-02 15:10:36 +01:00
Fix billing_test.go
This commit is contained in:
parent
e70e544c1a
commit
55f369d8c8
|
@ -3,35 +3,37 @@ package paypal_test
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
paypal "github.com/plutov/paypal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BillingExample() {
|
func BillingExample() {
|
||||||
plan := BillingPlan{
|
plan := paypal.BillingPlan{
|
||||||
Name: "Plan with Regular and Trial Payment Definitions",
|
Name: "Plan with Regular and Trial Payment Definitions",
|
||||||
Description: "Plan with regular and trial payment definitions.",
|
Description: "Plan with regular and trial payment definitions.",
|
||||||
Type: "fixed",
|
Type: "fixed",
|
||||||
PaymentDefinitions: []PaymentDefinition{
|
PaymentDefinitions: []paypal.PaymentDefinition{
|
||||||
{
|
{
|
||||||
Name: "Regular payment definition",
|
Name: "Regular payment definition",
|
||||||
Type: "REGULAR",
|
Type: "REGULAR",
|
||||||
Frequency: "MONTH",
|
Frequency: "MONTH",
|
||||||
FrequencyInterval: "2",
|
FrequencyInterval: "2",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "100",
|
Value: "100",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
Cycles: "12",
|
Cycles: "12",
|
||||||
ChargeModels: []ChargeModel{
|
ChargeModels: []paypal.ChargeModel{
|
||||||
{
|
{
|
||||||
Type: "SHIPPING",
|
Type: "SHIPPING",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "10",
|
Value: "10",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: "TAX",
|
Type: "TAX",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "12",
|
Value: "12",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
|
@ -43,22 +45,22 @@ func BillingExample() {
|
||||||
Type: "trial",
|
Type: "trial",
|
||||||
Frequency: "week",
|
Frequency: "week",
|
||||||
FrequencyInterval: "5",
|
FrequencyInterval: "5",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "9.19",
|
Value: "9.19",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
Cycles: "2",
|
Cycles: "2",
|
||||||
ChargeModels: []ChargeModel{
|
ChargeModels: []paypal.ChargeModel{
|
||||||
{
|
{
|
||||||
Type: "SHIPPING",
|
Type: "SHIPPING",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "1",
|
Value: "1",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: "TAX",
|
Type: "TAX",
|
||||||
Amount: AmountPayout{
|
Amount: paypal.AmountPayout{
|
||||||
Value: "2",
|
Value: "2",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
|
@ -66,8 +68,8 @@ func BillingExample() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MerchantPreferences: &MerchantPreferences{
|
MerchantPreferences: &paypal.MerchantPreferences{
|
||||||
SetupFee: &AmountPayout{
|
SetupFee: &paypal.AmountPayout{
|
||||||
Value: "1",
|
Value: "1",
|
||||||
Currency: "USD",
|
Currency: "USD",
|
||||||
},
|
},
|
||||||
|
@ -78,7 +80,7 @@ func BillingExample() {
|
||||||
MaxFailAttempts: "0",
|
MaxFailAttempts: "0",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
c, err := NewClient("clientID", "secretID", APIBaseSandBox)
|
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -92,18 +94,18 @@ func BillingExample() {
|
||||||
}
|
}
|
||||||
err = c.ActivatePlan(planResp.ID)
|
err = c.ActivatePlan(planResp.ID)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
agreement := BillingAgreement{
|
agreement := paypal.BillingAgreement{
|
||||||
Name: "Fast Speed Agreement",
|
Name: "Fast Speed Agreement",
|
||||||
Description: "Agreement for Fast Speed Plan",
|
Description: "Agreement for Fast Speed Plan",
|
||||||
StartDate: JSONTime(time.Now().Add(time.Hour * 24)),
|
StartDate: paypal.JSONTime(time.Now().Add(time.Hour * 24)),
|
||||||
Plan: BillingPlan{ID: planResp.ID},
|
Plan: paypal.BillingPlan{ID: planResp.ID},
|
||||||
Payer: Payer{
|
Payer: paypal.Payer{
|
||||||
PaymentMethod: "paypal",
|
PaymentMethod: "paypal",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resp, err := c.CreateBillingAgreement(agreement)
|
resp, err := c.CreateBillingAgreement(agreement)
|
||||||
fmt.Println(err, resp)
|
fmt.Println(err, resp)
|
||||||
|
|
||||||
bps, err := c.ListBillingPlans(BillingPlanListParams{Status: "ACTIVE"})
|
bps, err := c.ListBillingPlans(paypal.BillingPlanListParams{Status: "ACTIVE"})
|
||||||
fmt.Println(err, bps)
|
fmt.Println(err, bps)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user