CyberSource SDK v0.0.1 CyberSourceSDK.Client View Source

This Client module handle all HTTPS requests to the CyberSource server. It takes some parameters and convert to HTTPS requests.

It support the following payments:

  • Android Pay
  • Apple Pay

It supports the following requests:

  • Authorization
  • Capture
  • Refund

Link to this section Summary

Link to this section Functions

Link to this function authorize(price, merchant_reference_code, card_type, encrypted_payment, bill_to \\ [], worker \\ :merchant) View Source

Create an authorization payment

For a normal account, bill_to is mandatory. If you ask CyberSource for a relaxed AVS check, bill_to can be optional.

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 use. (Optional)

Example

Without bill_to and worker parameters

authorize(32.0, "1234", "VISA", "oJ8IOx6SA9HNncxzpS9akm32n+DSAJH==")

With bill_to parameter

bill_to = CyberSourceSDK.bill_to("John", "Doe", "Marylane Street", "34", "New York", "Hong Kong", "john@example.com")
authorize(32.0, "1234", "VISA", "oJ8IOx6SA9HNncxzpS9akm32n+DSAJH==", bill_to)
Link to this function capture(order_id, request_params, items \\ [], worker \\ :merchant) View Source

Capture authorization on user credit card

Parameters

  • order_id: Unique number to identify the purchase.
  • request_params: Base64 of a JSON with request_id and request_token from authorization request.
  • items: An array of map containing the following values: id, unit_price and quantity. Example: %{id: id, unit_price: unit_price, quantity: quantity}
  • worker: Merchant atom to use (setup in configurations).

Result

On successful return the result will be:

{:ok, object}
Link to this function pay_with_android_pay(price, merchant_reference_code, card_type, encrypted_payment, bill_to \\ [], worker \\ :merchant) View Source

Make a request to pay with Android Pay

Returns {:ok, response_object} , {:error, :card_type_not_found or {:error, response_code}

Link to this function pay_with_apple_pay(price, merchant_reference_code, card_type, encrypted_payment, request_id, bill_to \\ [], worker \\ :merchant) View Source

Make a request to pay with Apple Pay

Returns {:ok, response_object} , {:error, :card_type_not_found or {:error, response_code}

Link to this function refund(order_id, amount, request_params, items \\ [], worker \\ :merchant) View Source

Remove authorization on user credit card

Parameters

  • order_id: Unique number to identify the purchase.
  • amount: Price (value) to refund.
  • request_params: Base64 of a JSON with request_id and request_token from authorization request.
  • items: An array of map containing the following values: id, unit_price and quantity. Example: %{id: id, unit_price: unit_price, quantity: quantity}
  • worker: Merchant atom to use (setup in configurations)

Example

refund("1234", 23435465442432, items)