|
// See |
|
// https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ |
|
// for full API documentation. |
|
package nvelop // import "github.com/mndrix/nvelop" |
|
|
|
import "net/url" |
|
|
|
type Channel string |
|
type CheckoutFlow string |
|
type Page string |
|
type PaymentReason string |
|
type PaymentMethod string |
|
type PaymentAction string |
|
|
|
const ( |
|
Sole CheckoutFlow = "Sole" |
|
Mark CheckoutFlow = "Mark" |
|
|
|
Billing Page = "Billing" |
|
Login Page = "Login" |
|
|
|
Merchant Channel = "Merchant" |
|
EbayItem Channel = "eBayItem" |
|
|
|
None PaymentReason = "None" |
|
Refund PaymentReason = "Refund" |
|
|
|
InstantOnly PaymentMethod = "InstantPaymentOnly" |
|
|
|
Sale PaymentAction = "Sale" |
|
Authorization PaymentAction = "Authorization" |
|
Order PaymentAction = "Order" |
|
) |
|
|
|
type SetExpressCheckoutRequest struct { |
|
Token string `nvelop:"TOKEN"` |
|
|
|
PaymentRequests []*PaymentRequest `nvelop:"PAYMENTREQUEST_"` |
|
MaximumAmount int `nvelop:"MAXAMT,money"` |
|
ReturnUrl *url.URL `nvelop:"RETURNURL"` |
|
CancelUrl *url.URL `nvelop:"CANCELURL"` |
|
CallbackUrl *url.URL `nvelop:"CALLBACK"` |
|
CallbackTimeout int `nvelop:"CALLBACKTIMEOUT"` |
|
CallbackVersion string `nvelop:"CALLBACKVERSION"` |
|
RequireConfirmedAddress bool `nvelop:"REQCONFIRMSHIPPING"` // TODO need way to omit field entirely |
|
NoShipping int `nvelop:"NOSHIPPING"` |
|
AllowNote bool `nvelop:"ALLOWNOTE"` |
|
AddressOverride bool `nvelop:"ADDROVERRIDE"` |
|
Locale string `nvelop:"LOCALECODE"` |
|
PageStyle string `nvelop:"PAGESTYLE"` |
|
HeaderImage *url.URL `nvelop:"HDRIMG"` |
|
PayflowColor string `nvelop:"PAYFLOWCOLOR"` |
|
CartBorderColor string `nvelop:"CARTBORDERCOLOR"` |
|
LogoImage *url.URL `nvelop:"LOGOIMG"` |
|
BuyerEmail string `nvelop:"EMAIL"` |
|
SolutionType CheckoutFlow `nvelop:"SOLUTIONTYPE"` |
|
LandingPage Page `nvelop:"LANDINGPAGE"` |
|
ChannelType Channel `nvelop:"CHANNELTYPE"` |
|
|
|
GiropaySuccessUrl *url.URL `nvelop:"GIROPAYSUCCESSURL"` |
|
GiropayCancelUrl *url.URL `nvelop:"GIROPAYCANCELURL"` |
|
BankTransferUrl *url.URL `nvelop:"BANKTXNPENDINGURL"` |
|
|
|
BrandName string `nvelop:"BRANDNAME"` |
|
CustomerServiceNumber string `nvelop:"CUSTOMERSERVICENUMBER"` |
|
Note string `nvelop:"NOTETOBUYER"` |
|
} |
|
|
|
func (*SetExpressCheckoutRequest) Service() Service { return Merchant } |
|
func (*SetExpressCheckoutRequest) Method() string { return "SetExpressCheckout" } |
|
|
|
type SetExpressCheckoutResponse struct { |
|
Response |
|
} |
|
|
|
type PaymentRequest struct { |
|
Id string `nvelop:"_PAYMENTREQUESTID"` |
|
Amount int `nvelop:"_AMT,money"` |
|
Currency string `nvelop;"_CURRENCYCODE"` |
|
Reason PaymentReason `nvelop:"_PAYMENTREASON"` |
|
ShipTo Address `nvelop:"_SHIPTO"` |
|
|
|
ItemAmount int `nvelop:"_ITEMAMT,money"` |
|
ShippingAmount int `nvelop:"_SHIPPINGAMT,money"` |
|
InsuranceAmount int `nvelop:"_INSURANCEAMT,money"` |
|
ShippingDiscount int `nvelop:"_SHIPDISCAMT,money"` // negative number |
|
InsuranceOffered bool `nvelop:"_INSURANCEOPTIONOFFERED"` // TODO boolean renders as "true" or "false" for this field |
|
HandlingAmount int `nvelop:"_HANDLINGAMT,money"` |
|
TaxAmount int `nvelop:"_TAXAMT,money"` |
|
Description string `nvelop:"_DESC"` |
|
Custom string `nvelop:"_CUSTOM"` |
|
InvoiceNumber string `nvelop:"_INVNUM"` |
|
NotifyUrl *url.URL `nvelop:"_NOTIFYURL"` |
|
MultiShipping bool `nvelop:"_MULTISHIPPING"` |
|
Note string `nvelop:"_NOTETEXT"` |
|
|
|
// error in the docs? field is only part of DoExpressCheckout response |
|
//TransactionId string `nvelop:"_TRANSACTIONID"` |
|
|
|
AllowedPayment PaymentMethod `nvelop:"_ALLOWEDPAYMENTMETHOD"` |
|
PaymentAction PaymentAction `nvelop:"_PAYMENTACTION"` |
|
Bucket int `nvelop:"_BUCKETCATEGORYTYPE"` |
|
LocationType int `nvelop:"_LOCATION_TYPE,v115"` |
|
LocationId string `nvelop:"_LOCATION_ID,v115"` |
|
|
|
// TODO this field needs L_PAYMENTREQUEST_n prefix instead of PAYMENTREQUEST_n |
|
Items []PaymentRequestItem |
|
} |
|
|
|
type PaymentRequestItem struct { |
|
Name string |
|
Description string |
|
Amount int // money |
|
Number string |
|
Quantity int |
|
TaxAmount int // money |
|
Weight int |
|
Length int |
|
Width int |
|
Height int |
|
WeightUnit string |
|
LengthUnit string |
|
WidthUnit string |
|
HeighUnit string |
|
} |
|
|
|
type Address struct { |
|
Name string `nvelop:"NAME"` |
|
Street string `nvelop:"STREET"` |
|
Street2 string `nvelop:"STREET2"` |
|
City string `nvelop:"CITY"` |
|
State string `nvelop:"STATE"` |
|
Zip string `nvelop:"ZIP"` |
|
Country string `nvelop:"COUNTRYCODE"` |
|
Phone string `nvelop:"PHONENUM"` |
|
} |