Documentation ¶
Index ¶
- Variables
- type Client
- type ClientOption
- type Configuration
- type ConfigurationOption
- type Environment
- type Error
- type ErrorResponse
- type PaymentPayload
- type PaymentResponse
- type PaymentResultResponse
- type Pkcs12
- type RefundPayload
- type RefundResponse
- type RefundResultResponse
- type Request
- type Response
- type Swish
- func (s Swish) Payment(ctx context.Context, payload *PaymentPayload) (*PaymentResponse, error)
- func (s Swish) PaymentResult(ctx context.Context, token string) (*PaymentResultResponse, error)
- func (s Swish) Refund(ctx context.Context, payload *RefundPayload) (*RefundResponse, error)
- func (s Swish) RefundResult(ctx context.Context, token string) (*RefundResultResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( // TestEnvironment contains the environment specific fields for the test environment. TestEnvironment = Environment{BaseURL: "https://mss.cpc.getswish.net/swish-cpcapi/api/v1", Certificate: certificate} // ProductionEnvironment contains the environment specific fields for the production environment. ProductionEnvironment = Environment{BaseURL: "https://cpc.getswish.net/swish-cpcapi/api/v1", Certificate: certificate} )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// contains filtered or unexported methods
}
Client is the interface implemented by types that can invoke the BankID REST API.
type Configuration ¶
type Configuration struct { Environment *Environment Pkcs12 *Pkcs12 }
Configuration contains the configuration specific fields.
func NewConfiguration ¶
func NewConfiguration(environment *Environment, pkcs12 *Pkcs12, options ...ConfigurationOption) *Configuration
NewConfiguration creates a new configuration.
type ConfigurationOption ¶
type ConfigurationOption func(*Configuration)
ConfigurationOption definition.
type Environment ¶
Environment contains the environment specific fields.
func NewEnvironment ¶
func NewEnvironment(baseURL string, certificate string) *Environment
NewEnvironment creates a new environment.
type Error ¶
type Error struct { Code string `json:"ErrorCode"` Message string `json:"ErrorMessage"` AdditionalInformation string `json:"additionalInformation"` }
Error contains fields specific for the API error.
type ErrorResponse ¶
type ErrorResponse []Error
ErrorResponse contains fields for the error response.
func (*ErrorResponse) Decode ¶
Decode reads the JSON-encoded value and stories it in a error response struct.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type PaymentPayload ¶
type PaymentPayload struct { // Payment reference supplied by theMerchant. This is not used by Swish but is included in responses back to the // client. This reference could for example be an order id or similar. If set the value must not exceed 35 characters // and only the following characters are allowed: [a-ö, A-Ö, 0-9, -] PayeePaymentReference string `json:"payeePaymentReference,omitempty"` // validate // URL that Swish will use to notify caller about the result of the payment request. The URL has to use HTTPS. CallbackURL string `json:"callbackUrl"` // validate // The registered Cell phone number of the person that makes the payment. It can only contain numbers and has to be // at least 8 and at most 15 digits. It also needs to match the following format in order to be found in // Swish: country code + cell phone number (without leading zero). E.g.: 46712345678 // If set, request is handled as E-Commerce payment. // If not set, request is handled as M- Commerce payment. PayerAlias string `json:"payerAlias,omitempty"` // validate // The social security number of the individual making the payment, // should match the registered value for payerAlias or the payment will not be accepted. PayerSSN string `json:"payerSSN,omitempty"` // Minimum age (in years) that the individual connected to the payerAlias has to be in order for the payment to // be accepted. Value has to be in the range of 1 to 99. AgeLimit string `json:"ageLimit,omitempty"` // validate // The Swish number of the payee. It needs to match with Merchant Swish number. PayeeAlias string `json:"payeeAlias"` // validate // The amount of money to pay. The amount cannot be less than 1 SEK and not more than // 999999999999.99 SEK. Valid value has to // be all digits or with 2 digit decimal separated with a period. Amount string `json:"amount"` // validate // The currency to use. Currently the only supported value is SEK. Currency string `json:"currency"` // validate // Merchant supplied message about the payment/order. Max 50 characters. // Allowed characters are the letters a-ö, A-Ö, the numbers 0-9 and any of the special characters :;.,?!()-”. Message string `json:"message,omitempty"` // validate` // contains filtered or unexported fields }
PaymentPayload holds the required and optional fields of the payment request.
type PaymentResponse ¶
type PaymentResponse struct { // Used as reference to this order when the client is started automatically. ID string `json:"id"` // Used to collect the status of the order. URL string `json:"url"` // Payment request token Token string // contains filtered or unexported fields }
PaymentResponse holds the information of a initiated payment request.
func (*PaymentResponse) Decode ¶
Decode reads the http response and stories it in a payment response struct.
func (*PaymentResponse) String ¶
func (p *PaymentResponse) String() string
type PaymentResultResponse ¶
type PaymentResultResponse struct { ID string `json:"id"` PayeePaymentReference string `json:"payeePaymentReference"` PaymentReference string `json:"paymentReference"` CallbackURL string `json:"callbackUrl"` PayerAlias string `json:"payerAlias"` PayeeAlias string `json:"payeeAlias"` Amount float32 `json:"amount"` Currency string `json:"currency"` Message string `json:"message"` Status string `json:"status"` DateCreated string `json:"dateCreated"` DatePaid string `json:"datePaid"` ErrorCode string `json:"errorCode"` ErrorMessage string `json:"errorMessage"` }
PaymentResultResponse holds the information of a initiated payment result request.
func (*PaymentResultResponse) Decode ¶
Decode reads the JSON-encoded response and stories it in a payment result response struct.
func (*PaymentResultResponse) String ¶
func (p *PaymentResultResponse) String() string
type RefundPayload ¶
type RefundPayload struct { // Payment reference supplied by the Merchant. This is not used by Swish but is included in responses back to the client. PayerPaymentReference string `json:"payerPaymentReference,omitempty"` // Payment reference to the original payment that this refund is for. OriginalPaymentReference string `json:"originalPaymentReference"` // validate // URL that Swish will use to notify caller about the outcome of the refund. The URL has to use HTTPS. CallbackURL string `json:"callbackUrl"` // validate // The Swish number of the Merchant that makes the refund payment. PayerAlias string `json:"payerAlias"` // validate // The Cell phone number of the person that receives the refund payment. PayeeAlias string `json:"payeeAlias,omitempty"` // validate // The amount of money to refund. // The amount cannot be less than 1 SEK and not more than // Moreover, the amount cannot exceed the remaining amount of the original payment that the refund is for. Amount string `json:"amount"` // validate // The currency to use. Currency string `json:"currency"` // validate // Merchant supplied message about the refund. Max 50 chars. // Allowed characters are the letters a-ö, A-Ö, the numbers 0-9 and any of the special characters :;.,?!()-”. Message string `json:"message,omitempty"` // validate // contains filtered or unexported fields }
RefundPayload holds the required and optional fields of the refund request.
type RefundResponse ¶
type RefundResponse struct { // Used as reference to this order when the client is started automatically. ID string `json:"id"` // Used to collect the status of the refund. URL string `json:"url"` // contains filtered or unexported fields }
RefundResponse contains fields specific for the refund response.
func (*RefundResponse) Decode ¶
Decode reads the JSON-encoded value and stories it in a refund response struct.
func (RefundResponse) String ¶
func (r RefundResponse) String() string
type RefundResultResponse ¶
type RefundResultResponse struct { ID string `json:"id"` PaymentReference string `json:"paymentReference"` PayerPaymentReference string `json:"payerPaymentReference"` OriginalPaymentReference string `json:"originalPaymentReference"` CallbackURL string `json:"callbackUrl"` PayerAlias string `json:"payerAlias"` PayeeAlias string `json:"payeeAlias"` Amount float32 `json:"amount"` Currency string `json:"currency"` Message string `json:"message"` Status string `json:"status"` DateCreated string `json:"dateCreated"` DatePaid string `json:"datePaid"` ErrorMessage string `json:"errorMessage"` AdditionalInformation string `json:"additionalInformation"` ErrorCode string `json:"errorCode"` }
RefundResultResponse contains fields specific for the refund result response.
func (*RefundResultResponse) Decode ¶
Decode reads the JSON-encoded value and stories it in a refund result response struct.
func (RefundResultResponse) String ¶
func (r RefundResultResponse) String() string
type Response ¶
Response is the interface implemented by types that holds the response context fields.
type Swish ¶
type Swish struct {
// contains filtered or unexported fields
}
Swish contains the validator and configuration context.
func (Swish) Payment ¶
func (s Swish) Payment(ctx context.Context, payload *PaymentPayload) (*PaymentResponse, error)
Payment - Initiates a payment request
Merchants and Technical Suppliers can send payment requests for both E-Commerce and M- Commerce to MSS.
Once MSS receives a “payment request” call, there are two answers that will be returned from MSS (unless error situation). The first answer is synchronous, the second one is asynchronous.
func (Swish) PaymentResult ¶
PaymentResult - Retrieves the payment result
The client can retrieve payment result information of an initiated payment request (successful or failed) If the previous create payment request call simulated a delayed error the response of the GET operation will have a status property with value ERROR and properties errorCode and errorMessage will be set accordingly
MSS stores the necessary information about each incoming “PaymentRequest request” in a cache which automatically expires every 24 hours or when the MSS server is restarted.
func (Swish) Refund ¶
func (s Swish) Refund(ctx context.Context, payload *RefundPayload) (*RefundResponse, error)
Refund - Initiates a refund request.
Merchants and Technical Suppliers can send refund request to MSS.
When MSS receives a “Refund request” there are three answers that will be returned from MSS (unless error situation). The first answer is synchronous, the second and third responses are asynchronous.
func (Swish) RefundResult ¶
RefundResult - Retrieves the refund result
The client can retrieve refund result information of an initiated refund request (successful or failed).
If the previous create refund request call simulated a delayed error the response of the GET operation will have a status property with value ERROR and properties errorCode and errorMessage will be set accordingly
MSS stores the necessary information about each incoming “Refund request” in a cache which automatically expires every 24 hours or when the MSS server is restarted.