CyberSource SDK v1.0.4 CyberSourceSDK View Source

This CyberSource module communicates with the Simple Order API service (SOAP) of CyberSource.

Link to this section Summary

Functions

Send an authorization request, making sure that the user have the necessary amount of money in his/her account.

Generate BillTo object to replace parameters in request XML

Send a capture request to charge the user account.

Send a refund request o remove the hold on user money.

Called when an application is started.

Link to this section Functions

Link to this function

authorize(price, merchant_reference_code, card_type, encrypted_payment, bill_to \\ [], worker \\ :merchant) View Source
authorize(float(), String.t(), String.t(), String.t(), [String.t()], atom()) ::
  {:ok} | {:error, atom()} | {:error, String.t()}

Send an authorization request, making sure that the user have the necessary amount of money in his/her account.

Parameters

  • price: Float that represents the price to be charged to the user.
  • merchant_reference_code: String that represents the order. Normally you should pass an unique identifier like order_id.
  • card_type: String with the name of card type, like VISA, MASTERCARD, etc.
  • encrypted_payment: String that must be in Base64 received by Apple/Android payment system.
  • bill_to: Structure generated by CyberSourceSDK.bill_to(). (Optional)
  • worker: Atom with name of the structure in configurations to be used. (Optional)
Link to this function

bill_to(first_name, last_name, street1, street2, city, country, email) View Source
bill_to(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) :: [String.t()]

Generate BillTo object to replace parameters in request XML

Examples

iex> CyberSourceSDK.bill_to("John", "Doe", "Main Street", "2 Left", "New York", "USA", "john@example.com")
[first_name: "John", last_name: "Doe", street1: "Main Street", street2: "2 Left", city: "New York", country: "USA", email: "john@example.com"]
Link to this function

capture(order_id, request_id, items \\ [], worker \\ :merchant) View Source
capture(String.t(), String.t(), list(), atom()) ::
  {:ok} | {:error, atom()} | {:error, String.t()}

Send a capture request to charge the user account.

Link to this function

pay_with_android_pay(price, merchant_reference_code, card_type, encrypted_payment, bill_to \\ [], worker \\ :merchant) View Source
pay_with_android_pay(
  float(),
  String.t(),
  String.t(),
  String.t(),
  [String.t()],
  atom()
) :: {:ok} | {:error, atom()} | {:error, String.t()}

Pay with Android Pay request

Link to this function

pay_with_apple_pay(price, merchant_reference_code, card_type, encrypted_payment, bill_to \\ [], worker \\ :merchant) View Source
pay_with_apple_pay(
  float(),
  String.t(),
  String.t(),
  String.t(),
  [String.t()],
  atom()
) :: {:ok} | {:error, atom()} | {:error, String.t()}

Pay with Apple Pay request

Link to this function

refund(order_id, request_id, items \\ [], worker \\ :merchant) View Source
refund(String.t(), String.t(), list(), atom()) ::
  {:ok} | {:error, atom()} | {:error, String.t()}

Send a refund request o remove the hold on user money.

Called when an application is started.

This function is called when an application is started using Application.start/2 (and functions on top of that, such as Application.ensure_started/2). This function should start the top-level process of the application (which should be the top supervisor of the application's supervision tree if the application follows the OTP design principles around supervision).

start_type defines how the application is started:

  • :normal - used if the startup is a normal startup or if the application is distributed and is started on the current node because of a failover from another node and the application specification key :start_phases is :undefined.
  • {:takeover, node} - used if the application is distributed and is started on the current node because of a failover on the node node.
  • {:failover, node} - used if the application is distributed and is started on the current node because of a failover on node node, and the application specification key :start_phases is not :undefined.

start_args are the arguments passed to the application in the :mod specification key (e.g., mod: {MyApp, [:my_args]}).

This function should either return {:ok, pid} or {:ok, pid, state} if startup is successful. pid should be the PID of the top supervisor. state can be an arbitrary term, and if omitted will default to []; if the application is later stopped, state is passed to the stop/1 callback (see the documentation for the c:stop/1 callback for more information).

use Application provides no default implementation for the start/2 callback.

Callback implementation for Application.start/2.