iyzico v1.3.1 Iyzico.Iyzipay
A module containing payment related functions.
Making a payment
In order to process a payment, one needs to create a Iyzico.PaymentRequest
struct, which consists of a payment card,
a buyer, two seperate addresses for shipping and billing and basket information (aka items).
payment_request =
%PaymentRequest{
locale: @current_locale,
conversation_id: "123456789",
price: "0.5",
paid_price: "0.7",
currency: :try,
basket_id: "B67832",
payment_channel: :web,
payment_group: :product,
payment_card: card,
installment: 1,
buyer: buyer,
shipping_address: shipping_address,
billing_address: billing_address,
basket_items: [
binocular_item,
game_item
]
}
With that Iyzico.PaymentRequest
, it is straightforward to process the request.
{:ok, payment, metadata} = process_payment_req(payment_request)
3D Secure support
Authenticity of a transaction can be enhanced using 3D Secure feature, which is optional, although some associations might require the use of 3D Secure explicitly.
3D Secure based transaction could performed with process_secure_payment_req/2
function, which is analogical to its insecure friend process_payment_req/3
.
Making a secure payment
Processing a secure payment is on par with insecure payments, what is more, secure payments require a callback URL since remote authority will finalize the transaction by making a call to given URL.
payment_request =
%SecurePaymentRequest{
locale: @current_locale,
conversation_id: "123456789",
price: "0.5",
paid_price: "0.7",
currency: :try,
basket_id: "B67832",
payment_channel: :web,
payment_group: :product,
payment_card: card,
installment: 1,
buyer: buyer,
shipping_address: shipping_address,
billing_address: billing_address,
basket_items: [
binocular_item,
game_item
],
callback_url: "https://some.domain.to/be-specified/"
}
Discussion
Although utilization of 3D secure featured transactions become overwhelming in terms of duration of the payment it is highly discouraged to perform insecure transactions directly, especially without concerning about customer’s consent. Secure transactions involve two-factor authentication provided by associations, hence displacing the responsibility of the developer to be not concerned about authenticity of the credit card information.
Common Options
:api_key
: API key to be used in authentication, optional. Configuration is used instead if not supplied.:api_secret
: API secret key to be used in authentication. Configuration is used instead if not supplied.
Link to this section Summary
Functions
Finalizes a valid secure payment artifact on the remote API
Instantiates the given secure payment request on the remote API
Processes the given payment request on the remote API
Same as process_payment_req/1
, but raises an Iyzico.PaymentProcessingError
exception in case of failure.
Otherwise returns successfully processed payment
Link to this section Functions
finalize_secure_payment_req(Iyzico.SecurePaymentHandle.t, Keyword.t) :: {:ok, Iyzico.Payment.t, Iyzico.Metadata.t} | {:error, atom}
Finalizes a valid secure payment artifact on the remote API.
Options
See common options.
init_secure_payment_req(Iyzico.SecurePaymentRequest.t, Keyword.t) :: {:ok, Iyzico.SecurePaymentArtifact.t, Iyzico.Metadata.t} | {:error, atom}
Instantiates the given secure payment request on the remote API.
Options
See common options.
process_payment_req(Iyzico.PaymentRequest.t, Keyword.t) :: {:ok, Iyzico.Payment.t, Iyzico.Metadata.t} | {:error, atom}
Processes the given payment request on the remote API.
Options
See common options.
Same as process_payment_req/1
, but raises an Iyzico.PaymentProcessingError
exception in case of failure.
Otherwise returns successfully processed payment.