API Docs and Change History

Default Implementation

By default, the SDK can handle capturing payment methods with no intervention. Just make the following call at SDK initialization time:

VNPayment.configurePaymentProcessing(BraintreePaymentProcessableFragment())

That’s it!

Custom Implementation

If you would like to handle capturing of payment methods yourself, please use the following guide:

  1. Create a Fragment that is an instance of PaymentProcessableFragment - to do this you’d need to conform the fragment to the PaymentProcessable interface.

  2. The SDK will call processPayment(paymentSelectionResultListener: PaymentSelectionResultListener) in your fragment. This is the SDK telling you it needs you to provide it a payment method. You’ll likely need to store the PaymentSelectionResultListener that was passed as a parameter so you can use it later to pass the data to the SDK. When this method is called - the SDK doesn’t care how you handle capturing or selecting a payment method. You can launch your UI here, do your payment method capturing, etc.

  3. When you’ve completed capturing/selecting of the payment method, you call onPaymentResult(paymentResult: PaymentResult) on the PaymentSelectionResultListener that was passed to you in processPayment(paymentSelectionResultListener: PaymentSelectionResultListener). PaymentResult is an interface that you’ll need to conform your object to in order to pass it back to the SDK in that method. That’s the end point of your integration - once the SDK receives the PaymentResult, it takes over again.

  4. If capturing the payment method is unsuccessful or the user closes the selection screen before its completed, you just need to call paymentSelectionResultListener.onCancel() from the PaymentSelectionResultListener the SDK passed to you in processPayment(paymentSelectionResultListener: PaymentSelectionResultListener).

  5. Once that fragment has been created, you just need to pass it to the SDK at initialization time:

    VNPayment.configurePaymentProcessing(YourFragment())
    

Updated: