Venmo PayFast
Follow this guide to add Venmo PayFast to your checkout.
- VENMO_PAYFAST - Venmo PayFast
Payment methods availability:
- Venmo PayFast since mSDK version 7.9.0
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": "TEAM_ID.BUNDLE_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")
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"];
[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")
OPPBraintreeConfig *config = [OPPBraintreeConfig venmoPayFastConfigWithUniversalLink:@"https://yourdomain/braintree-payments"];
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'
App Switch
Currently, the App Switch flow is not functional and only the web flow works end to end. If the Venmo app is installed on the user’s device then it will trigger Venmo app but it will not return the result back to the app successfully. This issue will be addressed in an upcoming release, so you can skip the App Switch section for now.
The App Switch will enable users who have a Venmo app installed on their phone to complete payments on the Venmo app.
Follow below given steps to set up App Switch flow:
- Refer Android Developers docs to register your app for App link. Example of assetlinks.json file is shown below:
[{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.example", // This should be the SHA256 fingerprints of your app's signing certificate. "sha256_cert_fingerprints": ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"] } }] } - Refer this link to register your app link on Braintree control panel. Add your app link url without https:// in the braintree control panel.
- Add below code in your AndroidManifest.xml to get the result back in App switch flow:
<activity android:name="com.oppwa.mobile.connect.payment.processor.braintree.BraintreeProcessorActivity" android:exported="true"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https"/> <data android:host="merchant-app.com"/> <!-- required if your app link contains a path --> <data android:pathPrefix="/path" /> </intent-filter /> </activity>
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("https://example.com");
CheckoutPaymentBrandConfig brandConfig = new CheckoutPaymentBrandConfig.Builder()
.setVenmoPayfastConfig(venmoPayfastConfig)
.build();
val venmoPayfastConfig = new VenmoPayfastConfig("https://example.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 appLinkReturnUrl as parameter.
VenmoPayfastConfig venmoPayfastConfig = new VenmoPayfastConfig("https://example.com");
val venmoPayfastConfig = new VenmoPayfastConfig("https://example.com");
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 VenmoPayfast
Transaction transaction = new Transaction(paymentParams);
val paymentParams = VenmoPayFastPaymentParams(checkoutId, Connect.ProviderMode.TEST, venmoPayfastConfig)
// no need to set ShopperResultUrl for VenmoPayfast
val transaction = Transaction(paymentParams)
3. Register ActivityResultLauncher object to launch Venmo Payfast launcher to initiate the transaction
To initiate VENMO_PAYFAST transaction you have to create ActivityResultLaucher object of BraintreeProcessorResultContract and launch with the transaction object created in step 2.
4. Submit transaction
Create OppPaymentProvider object and call submit transaction by passing the transaction object received in Step 3. and the ITransactionListener callback parameter.
OppPaymentProvider paymentProvider = OppPaymentProvider(this, Connect.ProviderMode.TEST);
paymentProvider.submitTransaction(transaction, this);
val paymentProvider = OppPaymentProvider(this, Connect.ProviderMode.TEST)
paymentProvider.submitTransaction(transaction, this)
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.