Customer Vault API

The Customer Vault API allows you to create customer profiles containing their payment information – i.e., tokens – and then to make repeat payments without having to directly access sensitive payment information. It is a highly efficient and secure method for enabling repeat customer payments.

Click the links below to view our code samples.

Verify That the Service Is Accessible

is_online = client.customer_vault_service.monitor

Customer Profile

Create a customer profile
profile = Paysafe::CustomerVault::Profile.new({
  merchantCustomerId: "0f8fad5bd9cb469fa16570867728950e",
  locale: "en_US",
  firstName: "John",
  lastName: "Smith",
  email: "john.smith@somedomain.com",
  phone: "713-444-5555"
})

response = client.customer_vault_service.create_profile profile
Create a customer profile using a single-use token
profile = Paysafe::CustomerVault::Profile.new({
  merchantCustomerId: "0f8fad5bd9cb469fa16570867728950e",
  locale: "en_US",
  firstName: "John",
  lastName: "Smith",
  email: "john.smith@somedomain.com",
  phone: "713-444-5555",
  card: { singleUseToken: "SCO0Jpx9JUP9hESh" }
 })

response = client.customer_vault_service.create_profile profile
Look up a customer profile
profile = Paysafe::CustomerVault::Profile.new({
  id: profile_id
})

response = client.customer_vault_service.get_profile profile
Update a customer profile
profile_obj = Paysafe::CustomerVault::Profile.new({
  id: profile_id
})

profile = client.customer_vault_service.get_profile profile_obj
profile.firstName = "Jack"
response = client.customer_vault_service.update_profile profile
Delete a customer profile
profile_obj = Paysafe::CustomerVault::Profile.new({
  id: profile_id
})

response = client.customer_vault_service.delete_profile profile_obj

Profile Addresses

Create a customer address
address = Paysafe::CustomerVault::Address.new({
  profileID: profile_id,
  nickName: "home",
  street: "100 Queen Street West",
  street2: "Unit 201",
  city: "Toronto",
  country: "CA",
  state: "ON",
  zip: "M5H 2N2",
  recipientName: "Jane Doe",
  phone: "647-788-3901"
})

response = client.customer_vault_service.create_address address
Look up a customer address
address_obj = Paysafe::CustomerVault::Address.new({
  id: address_id,
  profileID: profile_id
})

response = client.customer_vault_service.get_address address_obj
Update a customer address
address_obj = Paysafe::CustomerVault::Address.new({
  id: address_id,
  profileID: profile_id
})

address = client.customer_vault_service.get_address address_obj
address.nickName = "NEW HOME"
response = client.customer_vault_service.update_address address
Delete a customer address
address_obj = Paysafe::CustomerVault::Address.new({
  id: address_id,
  profileID: profile_id
})

response = client.customer_vault_service.delete_address address_obj

Profile Cards

Create a customer card
card_obj = Paysafe::CustomerVault::Card.new({
  profileID: profile_id
  nickName: "John's corporate Visa",
  cardNum: "4111111111111111",
  cardExpiry: {
    month: "06",
    year: "2020"
  },
billingAddressId: address_id
})

response = client.customer_vault_service.create_card card_obj
Look up a customer card
card_obj = Paysafe::CustomerVault::Card.new({
  id: card_id,
  profileID: profile_id
})

response = client.customer_vault_service.get_card card_obj
Update a customer card
card_obj = Paysafe::CustomerVault::Card.new({
  id: card_id,
  profileID: profile_id,
})
card_obj.nickName = "NEW CARD NAME"
card = client.customer_vault_service.update_card card_obj
Delete a customer card
card_obj = Paysafe::CustomerVault::Card.new({
  id: card_id,
  profileID: profile_id
})

response = client.customer_vault_service.delete_card card_obj

Profile Bank Accounts

Managing ACH Bank Accounts

Create an ACH bank account
ach_bank_account_obj = Paysafe::CustomerVault::AchBankAccount.new({
      nickName: "John",
      accountNumber: rand(1000..10000000000000000),
      routingNumber: "123456789",
      accountHolderName: "XYZ Business",
      billingAddressId: address_id,
      accountType: "CHECKING",
      profileID: profile_id
    })

response = get_client.customer_vault_service.create_ach_bank_account ach_bank_account_obj
Look up an ACH bank account
ach_bank_account_obj = Paysafe::CustomerVault::AchBankAccount.new({
      id: ach_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.get_ach_bank_account ach_bank_account_obj
Update an ACH bank account
ach_bank_account_obj = Paysafe::CustomerVault::AchBankAccount.new({
      id: ach_bank_account_id,
      profileID: profile_id
    })
account_obj = get_client.customer_vault_service.get_ach_bank_account ach_bank_account_obj
account_obj.nickName = "NEW ACCOUNT NAME"
response = get_client.customer_vault_service.update_ach_bank_account account_obj
Delete an ACH bank account
ach_bank_account_obj = Paysafe::CustomerVault::AchBankAccount.new({
      id: ach_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.delete_ach_bank_account ach_bank_account_obj

Managing BACS Bank Accounts

Create a BACS bank account
bacs_bank_account_obj = Paysafe::CustomerVault::BacsBankAccount.new({
      nickName: "Sally's Account",
      sortCode: "070116",
      accountHolderName: "Tim",
      accountNumber: "34898396",
      billingAddressId: address_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.create_bacs_bank_account bacs_bank_account_obj
Create a BACS bank account with a mandate
bacs_bank_account_obj_mandate = Paysafe::CustomerVault::BacsBankAccount.new({
        nickName: "Sally's Barclays Account",
        accountNumber: "34898396",
        sortCode: "070116",
        accountHolderName: "Sally",
        billingAddressId: address_id,
        profileID: profile_id,
        mandates: [
        reference: "ABCDEFGHIJ",
        ]
      })
 response = get_bacs_client.customer_vault_service.create_bacs_bank_account_with_mandate bacs_bank_account_obj_mandate
Look up a BACS bank account
bacs_bank_account_obj = Paysafe::CustomerVault::BacsBankAccount.new({
      id: bacs_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.get_bacs_bank_account bacs_bank_account_obj
Update a BACS bank account
bacs_bank_account_obj = Paysafe::CustomerVault::BacsBankAccount.new({
        id: bacs_bank_account_id,
        profileID: profile_id
      })
account_obj = get_client.customer_vault_service.get_bacs_bank_account bacs_bank_account_obj
account_obj.nickName = "Sally's Account"
response = get_client.customer_vault_service.update_bacs_bank_account account_obj
Delete a BACS bank account
bacs_bank_account_obj = Paysafe::CustomerVault::BacsBankAccount.new({
      id: bacs_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.delete_bacs_bank_account bacs_bank_account_obj

Managing EFT Bank Accounts

Create an EFT bank account
eft_bank_account_obj = Paysafe::CustomerVault::EftBankAccount.new({
      nickName: "Sally's Bank of Montreal Account",
      accountNumber: rand(1000..10000000000),
      transitNumber: "25039",
      accountHolderName: "LMN Business",
      billingAddressId: address_id,
      institutionId: "001",
      profileID: profile_id
    })
response = get_client.customer_vault_service.create_eft_bank_account eft_bank_account_obj
Look up an EFT bank account
eft_bank_account_obj = Paysafe::CustomerVault::EftBankAccount.new({
      id: eft_bank_account_id,
      profileID: profile_id,
    })
response = get_client.customer_vault_service.get_eft_bank_account eft_bank_account_obj
Update an EFT bank account
eft_bank_account_obj = Paysafe::CustomerVault::EftBankAccount.new({
      id: eft_bank_account_id,
      profileID: profile_id
    })
account_obj = get_client.customer_vault_service.get_eft_bank_account eft_bank_account_obj
account_obj.nickName = "Sally's Bank of Montreal Account"
response = get_client.customer_vault_service.update_eft_bank_account account_obj
Delete an EFT bank account
eft_bank_account_obj = Paysafe::CustomerVault::EftBankAccount.new({
      id: eft_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.delete_eft_bank_account eft_bank_account_obj

Managing SEPA Bank Accounts

Create a SEPA bank account
sepa_bank_account_obj = Paysafe::CustomerVault::SepaBankAccount.new({
      nickName: "Sally's Account",
      iban: "TR079861528612024839757894",
      bic: "ABNANL2A",
      accountHolderName: "Tim",
      billingAddressId: address_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.create_sepa_bank_account sepa_bank_account_obj
Create a SEPA bank account with a mandate
sepa_bank_account_obj_mandate = Paysafe::CustomerVault::SepaBankAccount.new({
      nickName: "Sally's Account",
      iban: "TR079861528612024839757894",
      bic: "ABNANL2A",
      accountHolderName: "Sally",
      billingAddressId: address_id,
      profileID: profile_id,
      mandates: [
      reference: "ABCDEFGHIJ10987",
      ]
    })
response = get_sepa_client.customer_vault_service.create_sepa_bank_account_with_mandate sepa_bank_account_obj_mandate
Look up a SEPA bank account
sepa_bank_account_obj = Paysafe::CustomerVault::SepaBankAccount.new({
      id: sepa_bank_account_id,
      profileID: profile_id,
    })
response = get_client.customer_vault_service.get_sepa_bank_account sepa_bank_account_obj
Update a SEPA bank account
sepa_bank_account_obj = Paysafe::CustomerVault::SepaBankAccount.new({
      id: sepa_bank_account_id,
      profileID: profile_id
    })
account_obj = get_client.customer_vault_service.get_sepa_bank_account sepa_bank_account_obj
account_obj.nickName = "Sally's Account"
response = get_client.customer_vault_service.update_sepa_bank_account account_obj
Delete a SEPA bank account
sepa_bank_account_obj = Paysafe::CustomerVault::SepaBankAccount.new({
      id: sepa_bank_account_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.delete_sepa_bank_account sepa_bank_account_obj

Mandates

Create a BACS bank account mandate
bacs_mandate_obj = Paysafe::CustomerVault::Mandate.new({
      reference: get_bacs_mandate_reference,
      bankAccountId: bacs_bank_account_id,
      profileID: profile_id
    })
response = get_bacs_client.customer_vault_service.create_bacs_mandate bacs_mandate_obj
Create a SEPA bank account mandate
sepa_mandate_obj = Paysafe::CustomerVault::Mandate.new({
      reference: "SUBSCRIPTION103",
      bankAccountId: sepa_bank_account_id,
      profileID: profile_id
    })
response = get_sepa_client.customer_vault_service.create_sepa_mandate sepa_mandate_obj
Look up a mandate
mandate_obj = Paysafe::CustomerVault::Mandate.new({
      id: mandate_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.get_mandate mandate_obj
Update a mandate
mandte_obj = Paysafe::CustomerVault::Mandate.new({
      id: mandate_id,
      profileID: profile_id
    })
mandate_res_obj = get_client.customer_vault_service.get_mandate mandte_obj
mandate_res_obj.status = "CANCELLED"
response = get_client.customer_vault_service.update_mandate mandate_res_obj
Delete a mandate
mandate_obj = Paysafe::CustomerVault::Mandate.new({
      id: mandate_id,
      profileID: profile_id
    })
response = get_client.customer_vault_service.delete_mandate mandate_obj

Process a Payment Using a Payment Token

Process an authorization with a payment token
auth_obj = Paysafe::CardPayments::Authorization.new({
  merchantRefNum: "0f8fad5bd9cb469fa16570867728950e",
  amount: 555,
  settleWithAuth: false,
  card: { paymentToken: card.paymentToken }
})

response = client.card_payment_service.authorize auth_obj
Verify a card using a payment token
verify_obj = Paysafe::CardPayments::Verification.new({
  merchantRefNum: "0f8fad5bd9cb469fa16570867728950e",
  card: { paymentToken: card.paymentToken }
})

response = client.card_payment_service.verify verify_obj
Did you find this page useful?