airwallex

package
v0.0.0-...-4d04b2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2025 License: MulanPSL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SendCodeLogin           SendCode = "/api/v1/authentication/login"
	SendCodePay                      = "/api/v1/pa/payment_intents/create"
	SendCodeCreateCustomers          = "/api/v1/pa/customers/create"
	SendCodeCreateRefund             = "/api/v1/pa/refunds/create"
)

Variables

This section is empty.

Functions

func ComputeHMAC

func ComputeHMAC(secretKey, message string) string

Types

type AirWallerRefundReq

type AirWallerRefundReq struct {
	Amount   decimal.Decimal `json:"amount"`
	Metadata struct {
		Id string `json:"id"`
	} `json:"metadata"`
	//PaymentAttemptId string `json:"payment_attempt_id"`
	PaymentIntentId string `json:"payment_intent_id"`
	Reason          string `json:"reason"`
	RequestId       string `json:"request_id"`
}

type AirWallerRefundResp

type AirWallerRefundResp struct {
	AcquirerReferenceNumber string  `json:"acquirer_reference_number"`
	Amount                  float64 `json:"amount"`
	CreatedAt               string  `json:"created_at"`
	Currency                string  `json:"currency"`
	Id                      string  `json:"id"`
	Metadata                struct {
		Id string `json:"id"`
	} `json:"metadata"`
	PaymentAttemptId string `json:"payment_attempt_id"`
	PaymentIntentId  string `json:"payment_intent_id"`
	Reason           string `json:"reason"`
	RequestId        string `json:"request_id"`
	Status           string `json:"status"`
	Code             string `json:"code"`
	Message          string `json:"message"`
	UpdatedAt        string `json:"updated_at"`
}

type AirWallexCancelPayReq

type AirWallexCancelPayReq struct {
	CancellationReason string `json:"cancellation_reason"`
	RequestId          string `json:"request_id"`
}

type AirWallexCancelPayRespData

type AirWallexCancelPayRespData struct {
	CreatedAt       string `json:"created_at"`
	Code            string `json:"code"`
	Message         string `json:"message"`
	Id              string `json:"id"`
	MerchantOrderId string `json:"merchant_order_id"`
	RequestId       string `json:"request_id"`
	Status          string `json:"status"`
	UpdatedAt       string `json:"updated_at"`
}

type AirWallexRefundNotofy

type AirWallexRefundNotofy struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	AccountId string `json:"account_id"`
	Data      struct {
		Object struct {
			Amount    decimal.Decimal `json:"amount"`
			CreatedAt string          `json:"created_at"`
			Currency  string          `json:"currency"`
			Id        string          `json:"id"`
			Metadata  struct {
				Id string `json:"id"`
			} `json:"metadata"`
			PaymentAttemptId string `json:"payment_attempt_id"`
			PaymentIntentId  string `json:"payment_intent_id"`
			Reason           string `json:"reason"`
			RequestId        string `json:"request_id"`
			Status           string `json:"status"`
			UpdatedAt        string `json:"updated_at"`
		} `json:"object"`
	} `json:"data"`
	CreatedAt string `json:"created_at"`
	Version   string `json:"version"`
}

type AirwallexReqData

type AirwallexReqData struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	AccountId string `json:"account_id"`
	Data      struct {
		Object struct {
			Amount         decimal.Decimal `json:"amount"`
			BaseAmount     decimal.Decimal `json:"base_amount"`
			BaseCurrency   string          `json:"base_currency"`
			CapturedAmount decimal.Decimal `json:"captured_amount"`
			CreatedAt      string          `json:"created_at"`
			Currency       string          `json:"currency"`
			Customer       struct {
				Email       string `json:"email"`
				FirstName   string `json:"first_name"`
				LastName    string `json:"last_name"`
				PhoneNumber string `json:"phone_number"`
			} `json:"customer"`
			Descriptor           string `json:"descriptor"`
			Id                   string `json:"id"`
			LatestPaymentAttempt struct {
				Amount             decimal.Decimal `json:"amount"`
				AuthenticationData struct {
					AvsResult string `json:"avs_result"`
					CvcCode   string `json:"cvc_code"`
					CvcResult string `json:"cvc_result"`
					DsData    struct {
						RetryCountForAuthDecline int `json:"retry_count_for_auth_decline"`
					} `json:"ds_data"`
					FraudData struct {
						Action      string        `json:"action"`
						RiskFactors []interface{} `json:"risk_factors"`
						Score       string        `json:"score"`
					} `json:"fraud_data"`
				} `json:"authentication_data"`
				AuthorizationCode string          `json:"authorization_code"`
				CapturedAmount    decimal.Decimal `json:"captured_amount"`
				CreatedAt         string          `json:"created_at"`
				Currency          string          `json:"currency"`
				Id                string          `json:"id"`
				MerchantOrderId   string          `json:"merchant_order_id"`
				PaymentIntentId   string          `json:"payment_intent_id"`
				PaymentMethod     struct {
					Card struct {
						Billing struct {
							Address struct {
								City        string `json:"city"`
								CountryCode string `json:"country_code"`
								Postcode    string `json:"postcode"`
								State       string `json:"state"`
								Street      string `json:"street"`
							} `json:"address"`
							Email       string `json:"email"`
							FirstName   string `json:"first_name"`
							LastName    string `json:"last_name"`
							PhoneNumber string `json:"phone_number"`
						} `json:"billing"`
						Bin               string `json:"bin"`
						Brand             string `json:"brand"`
						CardType          string `json:"card_type"`
						CvcCheck          string `json:"cvc_check"`
						ExpiryMonth       string `json:"expiry_month"`
						ExpiryYear        string `json:"expiry_year"`
						Fingerprint       string `json:"fingerprint"`
						IsCommercial      bool   `json:"is_commercial"`
						IssuerCountryCode string `json:"issuer_country_code"`
						IssuerName        string `json:"issuer_name"`
						Last4             string `json:"last4"`
						Name              string `json:"name"`
						NumberType        string `json:"number_type"`
					} `json:"card"`
					Type string `json:"type"`
				} `json:"payment_method"`
				PaymentMethodOptions struct {
					Card struct {
						AuthorizationType string `json:"authorization_type"`
					} `json:"card"`
				} `json:"payment_method_options"`
				ProviderOriginalResponseCode string          `json:"provider_original_response_code"`
				ProviderTransactionId        string          `json:"provider_transaction_id"`
				RefundedAmount               decimal.Decimal `json:"refunded_amount"`
				SettleVia                    string          `json:"settle_via"`
				Status                       string          `json:"status"`
				UpdatedAt                    string          `json:"updated_at"`
			} `json:"latest_payment_attempt"`
			MerchantOrderId string `json:"merchant_order_id"`
			Metadata        struct {
				Id string `json:"id"`
			} `json:"metadata"`
			Order struct {
				Discount struct {
					CouponCode string `json:"coupon_code"`
				} `json:"discount"`
				Products []struct {
					Category         string    `json:"category"`
					Code             string    `json:"code"`
					Desc             string    `json:"desc"`
					EffectiveEndAt   time.Time `json:"effective_end_at"`
					EffectiveStartAt time.Time `json:"effective_start_at"`
					ImageUrl         string    `json:"image_url"`
					Name             string    `json:"name"`
					Quantity         int       `json:"quantity"`
					Seller           struct {
						Identifier string `json:"identifier"`
						Name       string `json:"name"`
					} `json:"seller"`
					Sku       string          `json:"sku"`
					Type      string          `json:"type"`
					UnitPrice decimal.Decimal `json:"unit_price"`
					Url       string          `json:"url"`
				} `json:"products"`
				Type string `json:"type"`
			} `json:"order"`
			RequestId string `json:"request_id"`
			ReturnUrl string `json:"return_url"`
			Status    string `json:"status"`
			UpdatedAt string `json:"updated_at"`
		} `json:"object"`
	} `json:"data"`
	CreatedAt string `json:"created_at"`
	Version   string `json:"version"`
}

type AirwallexService

type AirwallexService struct {
	Channel         consts.SysIncomeChannel
	IsSandbox       bool
	XClientId       string
	XApiKey         string
	PayServerKey    string
	RefundServerKey string
	TransactionRate decimal.Decimal
	Fee             decimal.Decimal
	FeeCurrency     string
	PayerOrgID      uint
	PayeeOrgID      uint
}

func (*AirwallexService) CancelPay

func (airwallexService *AirwallexService) CancelPay(tx context.Context, paymentID string) error

func (*AirwallexService) Init

func (airwallexService *AirwallexService) Init(
	isSandbox bool,
	xClientId string,
	xApiKey string,
	payServerKey string,
	refundServerKey string,
	transactionRate decimal.Decimal,
	fee decimal.Decimal,
	feeCurrency string,
)

func (*AirwallexService) Notify

func (airwallexService *AirwallexService) Notify(ctx *gin.Context) (*model2.PaymentNotification, error)

func (*AirwallexService) Pay

func (airwallexService *AirwallexService) Pay(ctx context.Context, payData *model2.PayData) (*model2.PaymentResponse, error)

func (*AirwallexService) Refund

func (airwallexService *AirwallexService) Refund(ctx context.Context, refundData *model2.RefundData) (string, error)

func (*AirwallexService) RefundNotify

func (airwallexService *AirwallexService) RefundNotify(ctx *gin.Context) (*model2.NotifyResponse, error)

type CreateCustomerAddress

type CreateCustomerAddress struct {
	City        string `json:"city"`
	CountryCode string `json:"country_code"`
	Postcode    string `json:"postcode"`
	State       string `json:"state"`
	Street      string `json:"street"`
}

type CreateCustomerReq

type CreateCustomerReq struct {
	Address      *CreateCustomerAddress `json:"address"`
	BusinessName string                 `json:"business_name"`
	Email        string                 `json:"email"`

	MerchantCustomerId string `json:"merchant_customer_id"`
	Metadata           struct {
		Id int `json:"id"`
	} `json:"metadata"`
	PhoneNumber string `json:"phone_number"`
	RequestId   string `json:"request_id"`
}

type CreateCustomerResp

type CreateCustomerResp struct {
	Address            *CreateCustomerAddress `json:"address"`
	BusinessName       string                 `json:"business_name"`
	ClientSecret       string                 `json:"client_secret"`
	CreatedAt          string                 `json:"created_at"`
	Email              string                 `json:"email"`
	FirstName          string                 `json:"first_name"`
	Id                 string                 `json:"id"`
	LastName           string                 `json:"last_name"`
	MerchantCustomerId string                 `json:"merchant_customer_id"`
	Metadata           struct {
		Id string `json:"id"`
	} `json:"metadata"`
	PhoneNumber string `json:"phone_number"`
	RequestId   string `json:"request_id"`
	UpdatedAt   string `json:"updated_at"`
}

type PayCustomer

type PayCustomer struct {
	Email     string `json:"email"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	//MerchantCustomerId string `json:"merchant_customer_id"`
	PhoneNumber string `json:"phone_number"`
}

type PayReq

type PayReq struct {
	Amount decimal.Decimal `json:"amount"`

	Currency   string `json:"currency"`
	CustomerId string `json:"customer_id"`

	Reference           string   `json:"reference"`
	Reusable            bool     `json:"reusable"`
	SupportedCurrencies []string `json:"supported_currencies"`
	Title               string   `json:"title"`
	ReturnUrl           string   `json:"return_url"`
}

type PayReqCollectableShopperInfo

type PayReqCollectableShopperInfo struct {
	Message         bool `json:"message"`
	PhoneNumber     bool `json:"phone_number"`
	Reference       bool `json:"reference"`
	ShippingAddress bool `json:"shipping_address"`
}

type PayReqData

type PayReqData struct {
	Amount decimal.Decimal `json:"amount"`
	//ConnectedAccountId string  `json:"connected_account_id"`
	Currency        string           `json:"currency"`
	Descriptor      string           `json:"descriptor"`
	MerchantOrderId string           `json:"merchant_order_id"`
	Order           *PayReqDataOrder `json:"order"`
	Customer        *PayCustomer     `json:"customer"`
	//PaymentMethodOptions struct {
	//	Card struct {
	//		AuthorizationType string `json:"authorization_type"`
	//		AutoCapture       bool   `json:"auto_capture"`
	//		RiskControl       struct {
	//			SkipRiskProcessing      bool   `json:"skip_risk_processing"`
	//			ThreeDomainSecureAction string `json:"three_domain_secure_action"`
	//			ThreeDsAction           string `json:"three_ds_action"`
	//		} `json:"risk_control"`
	//		ThreeDsAction string `json:"three_ds_action"`
	//	} `json:"card"`
	//} `json:"payment_method_options"`
	Metadata struct {
		Id string `json:"id"`
	} `json:"metadata"`
	RequestId string `json:"request_id"`
	ReturnUrl string `json:"return_url"`
}

type PayReqDataItineraries

type PayReqDataItineraries struct {
	AirlineCarrierCode   string `json:"airline_carrier_code"`
	ArrivalAirportCode   string `json:"arrival_airport_code"`
	ArrivalCity          string `json:"arrival_city"`
	ArriveAt             string `json:"arrive_at"`
	DepartAt             string `json:"depart_at"`
	DepartureAirportCode string `json:"departure_airport_code"`
	DepartureCity        string `json:"departure_city"`
	Insurance            []struct {
		Company string `json:"company"`
		Price   int    `json:"price"`
		Type    string `json:"type"`
	} `json:"insurance"`
	Price              decimal.Decimal `json:"price"`
	ServiceClass       string          `json:"service_class"`
	TravelerIdentifier string          `json:"traveler_identifier"`
}

type PayReqDataOrder

type PayReqDataOrder struct {
	Discount struct {
		CouponCode string `json:"coupon_code"`
	} `json:"discount"`
	Products    []*PayReqDataOrderProducts `json:"products"`
	Itineraries []*PayReqDataItineraries   `json:"itineraries"`
	Type        string                     `json:"type"`
}

type PayReqDataOrderProducts

type PayReqDataOrderProducts struct {
	Category         string    `json:"category"`
	Code             string    `json:"code"`
	Desc             string    `json:"desc"`
	EffectiveEndAt   time.Time `json:"effective_end_at"`
	EffectiveStartAt time.Time `json:"effective_start_at"`
	ImageUrl         string    `json:"image_url"`
	Name             string    `json:"name"`
	Quantity         int       `json:"quantity"`
	Seller           struct {
		Identifier string `json:"identifier"`
		Name       string `json:"name"`
	} `json:"seller"`
	Sku       string          `json:"sku"`
	Type      string          `json:"type"`
	UnitPrice decimal.Decimal `json:"unit_price"`
	Url       string          `json:"url"`
}

type PayResp

type PayResp struct {
	Active                 bool    `json:"active"`
	Amount                 float64 `json:"amount"`
	CollectableShopperInfo struct {
		Message         bool `json:"message"`
		PhoneNumber     bool `json:"phone_number"`
		Reference       bool `json:"reference"`
		ShippingAddress bool `json:"shipping_address"`
	} `json:"collectable_shopper_info"`
	CreatedAt                       string `json:"created_at"`
	Currency                        string `json:"currency"`
	CustomerId                      string `json:"customer_id"`
	DefaultCurrency                 string `json:"default_currency"`
	Description                     string `json:"description"`
	ExpiresAt                       string `json:"expires_at"`
	Id                              string `json:"id"`
	LatestSuccessfulPaymentIntentId string `json:"latest_successful_payment_intent_id"`
	Metadata                        struct {
		OrderId string `json:"order_id"`
	} `json:"metadata"`
	Reference                    string   `json:"reference"`
	Reusable                     bool     `json:"reusable"`
	Status                       string   `json:"status"`
	SuccessfulPaymentIntentCount int      `json:"successful_payment_intent_count"`
	SupportedCurrencies          []string `json:"supported_currencies"`
	Title                        string   `json:"title"`
	UpdatedAt                    string   `json:"updated_at"`
	Url                          string   `json:"url"`
}

type PayRespData

type PayRespData struct {
	Id              string  `json:"id"`
	RequestId       string  `json:"request_id"`
	Amount          float64 `json:"amount"`
	Currency        string  `json:"currency"`
	MerchantOrderId string  `json:"merchant_order_id"`
	Descriptor      string  `json:"descriptor"`
	Metadata        struct {
		Id string `json:"id"`
	} `json:"metadata"`
	Status                      string   `json:"status"`
	CapturedAmount              int      `json:"captured_amount"`
	CreatedAt                   string   `json:"created_at"`
	UpdatedAt                   string   `json:"updated_at"`
	AvailablePaymentMethodTypes []string `json:"available_payment_method_types"`
	ClientSecret                string   `json:"client_secret"`
	BaseAmount                  float64  `json:"base_amount"`
	BaseCurrency                string   `json:"base_currency"`
	ReturnUrl                   string   `json:"return_url"`
	Code                        string   `json:"code"`
	Message                     string   `json:"message"`
}

type RespToken

type RespToken struct {
	ExpiresAt string `json:"expires_at"`
	Token     string `json:"token"`
}

type SendCode

type SendCode string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL