JS SDK checkout (Swift)

Create your own checkout connected to multiple payment gateways, keeping you PCI Compliant for one-time and recurring charges.

Rebill SDK

In general, all the methods enabled in the SDK are in the Rebill class.

For example, to create a customer you need to call the Rebill class the following way:

Rebill.shared.create(customer: customer) { [weak self] cust in self?.view.show(results: "Success creating customer (customer.user)") self?.view.stopLoading() } failure: { [weak self] error in self?.view.show(results: "Failed creating customer") self?.view.stopLoading() }

As you can see, Rebill.shared. is always used to call all of Rebill's methods.

We must follow a few steps to create a successful payment, but before that we need to know some basic entities.

Customer

Here is your customer data, where only the first name, last name and email are required.

An example of how the fields should be filled in and which fields are supported:

let user = RebillUser(email: "[email protected]", password: "Test1_1234") let phone = RebillPhone(countryCode: 54, areaCode: 11, number: 26423002) let taxtId = RebillTaxId(type: "CUIT", value: "20386172618") let personalId = RebillPersonalId(type: "DNI", value: "38617261") let address = RebillAddress(street: "Arenales", city: "Vicente Lopez", state: "Buenos Aires", country: "Argentina", zipCode: "1636")
let profile = RebillProfile(phone: phone, taxtId: taxtId, personalId: personalId, address: address, firstName: "Test", lastName: "Testin", birthday: Date(timeIntervalSince1970: 784927164))
let customer = RebillCustomer(user: user, profile: profile)

Checkout customer for non-PCI

Here is the data to create a customer to do a non-PCI checkout:

let fistName = "Jose" let lastName = "Sanchez" let email = "[email protected]" let personalId = RebillPersonalId(type: "DNI", value: "38617261") let phone = RebillPhone(countryCode: 54, areaCode: 11, number: 26423002) let address = RebillAddress(street: "Arenales", city: "Vicente Lopez", state: "Buenos Aires", country: "AR", zipCode: "1638", number: 554) RebillNoPCICheckoutCustomer(firstName: fistName, lastName: lastName, email: email, personalId: personalId, phone: phone, address: address)

Practical example

The SDK can be used whether you are a PCI Compliant customer or not.

If you are not PCI Compliant, Rebill provides you a ViewController that encapsulates the logic of card loading and payment execution so you don't have to control sensitive data.

If you are PCI Compliant, you can use the view provided by Rebill or even your own view for the payment execution, as well as using manual checkout methods.

In general, to use the SDK you must follow the first 2 steps:

  1. Add the pod to your Podfile.
pod 'RebillSDK' ~> '1.0'

2 - Run the command: pod install.

Checkout for non-PCI compliant clients

A view controller provided by the Rebill SDK will be used, in charge of making the payments. In turn, a delegate and a datasource must be passed to catch the events and provide the necessary data to work.

self.view = Rebill.shared.getPaymentController(delegate: self, datasource: self)
// MARK: Payment Delegate and Datasource extension CardAppRouter: RebillPaymentViewControllerDelegate { func didCheckoutPayment(sender: UIViewController) { // TODO: Routear a una pantalla de succes print("Did checkout payment") style.routeBack() }
func didFailCheckoutPayment(sender: UIViewController) {
    print("Didnt checkout payment")
    style.routeBack()
}

}
extension CardAppRouter: RebillPaymentViewControllerDataSource { func customer(sender: UIViewController) -> RebillNoPCICheckoutCustomer { let fistName = "Jose" let lastName = "Sanchez" let email = "[email protected]" let personalId = RebillPersonalId(type: "DNI", value: "38617261") let phone = RebillPhone(countryCode: 54, areaCode: 11, number: 26423002) let address = RebillAddress(street: "Arenales", city: "Vicente Lopez", state: "Buenos Aires", country: "AR", zipCode: "1638", number: 554) return RebillNoPCICheckoutCustomer(firstName: fistName, lastName: lastName, email: email, personalId: personalId, phone: phone, address: address) }
func prices(sender: UIViewController) -> [RebillPrice] {
    return [RebillPrice(id: "9589ebf8-991a-41f9-a6d5-b89bf3b3f663", quantity: 1)]
}

func organizationId(sender: UIViewController) -> String {
    return "50f34816-040b-4cde-9bf3-b7a13265cba0"
}

}

Checkout for PCI compliant clients

If you are a PCI Compliant customer, you can manage credit cards and its information. Therefore, we provide you a view to catch and return card information.

self.view = Rebill.shared.getPaymentController(delegate: self, datasource: self)
// MARK: Card Delegate extension CardAppRouter: RebillCardViewControllerDelegate { func didCreate(sender: UIViewController, card: RebillCheckoutCard) { print("Card returned") style.routeBack() } }

More practical examples

For more examples, you can always check the project's testapp in the RebillSDK/ folder.