CyberSource SDK v0.0.6 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
Functions
Create an authorization payment
Capture authorization on user credit card
Make a request to pay with Android Pay
Make a request to pay with Apple Pay
Remove authorization on user credit card
Link to this section Functions
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)
Capture authorization on user credit card
Parameters
- order_id: Unique number to identify the purchase.
- request_params: Base64 of a JSON with
request_id
andrequest_token
from authorization request. - items: An array of map containing the following values:
id
,unit_price
andquantity
. 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}
Make a request to pay with Android Pay
Returns {:ok, response_object}
, {:error, :card_type_not_found
or
{:error, response_code}
Make a request to pay with Apple Pay
Returns {:ok, response_object}
, {:error, :card_type_not_found
or
{:error, response_code}
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
andrequest_token
from authorization request. - items: An array of map containing the following values:
id
,unit_price
andquantity
. Example:%{id: id, unit_price: unit_price, quantity: quantity}
- worker: Merchant atom to use (setup in configurations)
Example
refund("1234", 23435465442432, items)