Venmo PayFast (Draft)
Follow this guide to add Venmo PayFast to your checkout.
- VENMO_PAYFAST - Venmo PayFast
Configuration
To integrate VENMO_PAYFAST you need to add the Braintree dependencies in your project. Please download the XCFrameforks and add the dependencies following steps below:
- Download and unzip Braintree framework from Github.
- Download and unzip PPRiskMagnes framework from Braintree Assets.
- Drag and drop
BraintreeCore.xcframeworkto the "Frameworks" folder of your project.
Make sure "Copy items if needed" is checked. - Drag and drop
BraintreeDataCollector.xcframeworkto the "Frameworks" folder of your project.
Make sure "Copy items if needed" is checked. - Drag and drop
BraintreeVenmo.xcframeworkto the "Frameworks" folder of your project.
Make sure "Copy items if needed" is checked. - Drag and drop
PPRiskMagnes.xcframeworkto the "Frameworks" folder of your project.
Make sure "Copy items if needed" is checked. - Check "Frameworks, Libraries, and Embedded Content" section under the general settings tab of your application's target. Ensure the Embed dropdown has Embed and Sign selected for the framework.
App Switch
App Switch enables buyers with the Venmo app installed to start checkout in a merchant app and seamlessly complete the flow in the Venmo app. This provides a low-friction authentication experience using native Venmo app login methods such as Face ID, biometrics, or passkeys.
Follow below given steps to set up switch flow:
- Refer this document to register your app for universal link. Your apple-app-site-association file should look like:
{ "applinks": { "details": [{ "appID": "com.your-app-id", "paths": ["/braintree-payments/*"] }] } } - To allow your app to detect and switch to the Venmo app, add the Venmo URL scheme to the LSApplicationQueriesSchemes allowlist in your app’s Info.plist:
<key>LSApplicationQueriesSchemes</key> <array> <string>com.venmo.touch.v2</string> </array> - You must have a display name in your app's info.plist to help Venmo identify your application:
<key>CFBundleDisplayName</key> <string>Your App Name</string>
-
To handle universal link callback add below given method to your UISceneDelegate class.
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { let success = OPPBraintreeProcessor.handleRedirection(userActivity) } func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { URLContexts.forEach { context in if context.url.scheme?.localizedCaseInsensitiveCompare("your_app_scheme") == .orderedSame { OPPBraintreeProcessor.handleRedirection(url: context.url) } } } - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity { BOOL success = [OPPBraintreeProcessor handleRedirection:userActivity]; } - (void)scene:(UIScene *)scene openURLContexts:(NSSet*)URLContexts { for (UIOpenURLContext *context in URLContexts) { if ([context.URL.scheme caseInsensitiveCompare:@"your_app_scheme"] == NSOrderedSame) { BOOL success = [OPPBraintreeProcessor handleRedirectionWithUrl:context.URL]; } } }
Ready-to-Use UI
When you use our ready-to-use UI, everything works out-of-box. Just set VENMO_PAYFAST payment brand and set Venmo PayFast config in checkout settings class and you are done. Proceed with the presenting checkout as for standard transaction.
let checkoutSettings = OPPCheckoutSettings()
// Set Venmo PayFast payment brand
checkoutSettings.paymentBrands = ["VENMO_PAYFAST"]
let config = OPPBraintreeConfig.venmoPayFastConfig(universalLink: "https://yourdomain/braintree-payments",
collectCustomerShippingAddress: false,
collectCustomerBillingAddress: false)
checkoutSettings.setBrandConfig(config)
OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
// Set Venmo PayFast payment brand
checkoutSettings.paymentBrands = @[@"VENMO_PAYFAST"];
OPPBraintreeConfig *config = [OPPBraintreeConfig venmoPayFastConfigWithUniversalLink:@"https://yourdomain/braintree-payments"
collectCustomerShippingAddress:NO
collectCustomerBillingAddress:NO];
[checkoutSettings setBrandConfig:config];
SDK & Your Own UI
In this guide we assume that you have already implemented all steps for performing standard mSDK transaction.
There are several steps that you have to perform to integrate Venmo PayFast, which are as follows:
1. Create Venmo PayFast brand configuration
Create Venmo PayFast brand configuration with universal link.
let config = OPPBraintreeConfig.venmoPayFastConfig(universalLink: "https://yourdomain/braintree-payments",
collectCustomerShippingAddress: false,
collectCustomerBillingAddress: false)
OPPBraintreeConfig *config = [OPPBraintreeConfig venmoPayFastConfigWithUniversalLink:@"https://yourdomain/braintree-payments"
collectCustomerShippingAddress:NO
collectCustomerBillingAddress:NO];
2. Create Venmo PayFast payment param
Use checkoutId and config object created earlier to create Venmo PayFast Payment params.
do {
let parameter = try OPPBraintreePaymentParams.venmoPayFastPaymentParamsWith(checkoutId:checkoutId,
config:config)
} catch let error as NSError {
// Handle error
}
NSError *error;
OPPBraintreePaymentParams *parameter = [OPPBraintreePaymentParams venmoPayFastPaymentParamsWithCheckoutId:checkoutId
config:config
error:&error];
3. Create transaction object from payment params
You have to create transaction object.
let transaction = OPPTransaction(paymentParams: parameter)
OPPTransaction *transaction = [[OPPTransaction alloc] initWithPaymentParams:parameter];
4. Create Braintree processor object to process transaction
You have to create OPPBraintreeProcessor object and call process method on it to process the transaction.
let processor = try OPPBraintreeProcessor(transaction:transaction,
mode:mode)
processor.process { (transaction, error) in
if let error = error {
// Handle error
} else {
// Submit transaction
}
}
NSError *error;
OPPBraintreeProcessor *processor = [[OPPBraintreeProcessor alloc] initWithTransaction:transaction
mode:mode
error:&error];
if (error) {
// Handle error
} else {
[processor process:^(OPPTransaction * _Nonnull, NSError * _Nullable) {
if (error) {
// Handle error
} else {
// Submit transaction
}
}];
}
5. Submit transaction
Create a payment provider object and call submit transaction from completion handler of process function.
let provider = OPPPaymentProvider(mode:providerMode)
self.provider.submitTransaction(transaction, completionHandler: {(transaction, error) in
// Get payment status
})
OPPPaymentProvider *provider = [OPPPaymentProvider paymentProviderWithMode:providerMode];
[provider submitTransaction:transaction completionHandler:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) {
// Get payment status
}];
6. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.
Configuration
Open the build.gradle file in the app module and add the following to the dependencies block
implementation 'com.braintreepayments.api:venmo:5.18.0'
implementation 'com.braintreepayments.api:data-collector:5.18.0'
Ready-to-Use UI
1. Create Venmo Payfast Config
Create Venmo Payfast config and set it to brand configuration using CheckoutPaymentBrandConfig.Builder
VenmoPayfastConfig venmoPayfastConfig = new VenmoPayfastConfig(false, false, "https://test.docs.oppwa.com");
CheckoutPaymentBrandConfig brandConfig = new CheckoutPaymentBrandConfig.Builder()
.setVenmoPayfastConfig(paypalPayfastConfig)
.build();
val venmoPayfastConfig = new VenmoPayfastConfig(false, false, "test.docs.oppwa.com");
val brandConfig = CheckoutPaymentBrandConfig.Builder()
.setVenmoPayfastConfig(venmoPayfastConfig)
.build()
2. Create CheckoutSettings
Create CheckoutSettings and set brand config
Set<String> paymentBrands = new LinkedHashSet<String>();
paymentBrands.add("VENMO_PAYFAST");
CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST);
checkoutSettings.setBrandConfig(brandConfig);
val paymentBrands = hashSetOf("VENMO_PAYFAST")
val checkoutSettings = CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST)
checkoutSettings.setBrandConfig(brandConfig)
SDK & Your Own UI
In this guide we assume that you have already implemented all steps for performing standard mSDK transaction.
There are several steps that you have to perform to integrate VENMO_PAYFAST, which are as follows:
1. Create Venmo Payfast brand configuration
Create Venmo Payfast brand configuration which takes collectCustomerShippingAddress, collectCustomerBillingAddress and appLinkReturnUrl as parameters.
VenmoPayfastConfig venmoPayfastConfig = new VenmoPayfastConfig(false, false, "https://test.docs.oppwa.com");
CheckoutPaymentBrandConfig brandConfig = new CheckoutPaymentBrandConfig.Builder()
.setVenmoPayfastConfig(venmoPayfastConfig)
.build();
val venmoPayfastConfig = new VenmoPayfastConfig(false, false, "test.docs.oppwa.com");
val brandConfig = CheckoutPaymentBrandConfig.Builder()
.setVenmoPayfastConfig(venmoPayfastConfig)
.build()
2. Create Venmo Payfast payment params
Use checkoutId, provider mode and brandConfiguration(venmoPayfastConfig) object created earlier to create VenmoPayfast Payment params.
VenmoPayFastPaymentParams paymentParams = new VenmoPayFastPaymentParams(checkoutId, Connect.ProviderMode.TEST, venmoPayfastConfig);
// no need to set ShopperResultUrl for PaypalPayfast
val paymentParams = VenmoPayFastPaymentParams(checkoutId, Connect.ProviderMode.TEST, paypalPayfastConfig)
// no need to set ShopperResultUrl for VenmoPayfast
3. Submit transaction
Create Transaction object by passing VenmoPayFastPaymentParams, then create payment provider object and call submit transaction.
Transaction transaction = new Transaction(paymentParams);
OppPaymentProvider paymentProvider = new OppPaymentProvider(this, Connect.ProviderMode.TEST);
paymentProvider.submitTransaction(transaction, this);
val transaction = Transaction(paymentParams)
val paymentProvider = OppPaymentProvider(this, Connect.ProviderMode.TEST)
paymentProvider.submitTransaction(transaction, this)
4. Register ActivityResultLauncher object to launch Venmo Payfast launcher to process the transaction
To complete VENMO_PAYFAST transaction after you receive a transaction object in the callback of step 3, you have to create ActivityResultLaucher object of VenmoPayfastProcessorResultContract and launch with that transaction.
5. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.