Pix
Follow this guide to add Pix to your checkout.
- PIX_VA - Pix
Payment method availability:
- Pix since mSDK version 7.9.0
iOS
Register custom URL scheme
Add the shopper result url in custom url scheme in your app's Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.companyname.appname.payments</string>
</array>
Ready-to-Use UI
When you use our ready-to-use UI, everything works out-of-box. Just set PIX_VA payment brand and shopper result url in the Checkout Settings class and you are done. Proceed with the presenting checkout as for standard transaction.
let checkoutSettings = OPPCheckoutSettings()
// Set Pix payment method
checkoutSettings.paymentBrands = ["PIX_VA"]
checkoutSettings.shopperResultURL = "com.companyname.appname.payments://result"
OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
// Set Pix payment methods
checkoutSettings.paymentBrands = @[@"PIX_VA"];
checkoutSettings.shopperResultURL = @"com.companyname.appname.payments://result";
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 PIX_VA, which are as follows:
1. Create PIX_VA payment param
Use checkoutId, document type and document Id to create PIX_VA payment params. You may use id card, passport or tax statement number as document id.
// Create PIX_VA payment param with id card number.
var params: OPPPixVaPaymentParams
do {
params = try OPPPixVaPaymentParams(checkoutID: checkoutID, identificationDocType: .idCard, identificationDocId: idCardNumber)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
// Create PIX_VA payment param with id card number.
NSError *error;
OPPPixVaPaymentParams *paymentParams = [[[OPPPixVaPaymentParams alloc] initWithCheckoutId:checkoutId identificationDocType:OPPIdentificationDocTypeIdCard identificationDocId:idCardNumber error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
// Create PIX_VA payment param with passport number.
var params: OPPPixVaPaymentParams
do {
params = try OPPPixVaPaymentParams(checkoutID: checkoutID, identificationDocType: .passport, identificationDocId: passportNumber)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
// Create PIX_VA payment param with passport number.
NSError *error;
OPPPixVaPaymentParams *paymentParams = [[[OPPPixVaPaymentParams alloc] initWithCheckoutId:checkoutId identificationDocType:OPPIdentificationDocTypePassport identificationDocId:passportNumber error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
// Create PIX_VA payment param with tax statement number.
var params: OPPPixVaPaymentParams
do {
params = try OPPPixVaPaymentParams(checkoutID: checkoutID, identificationDocType: .taxStatement, identificationDocId: taxStatementNumber)
params.shopperResultURL = shopperResultURL
} catch let error as NSError {
// Handle the error
}
// Create PIX_VA payment param with tax statement number.
NSError *error;
OPPPixVaPaymentParams *paymentParams = [[[OPPPixVaPaymentParams alloc] initWithCheckoutId:checkoutId identificationDocType:OPPIdentificationDocTypeTaxStatement identificationDocId:taxStatementNumber error:&error];
paymentParams.shopperResultURL = @"com.companyname.appname.payments://result";
2. Submit transaction
Create a payment provider object and call submit transaction.
let provider = OPPPaymentProvider(mode: providerMode)
self.provider.submitTransaction(transaction, completionHandler: {(transaction, error) in
// Open transaction.redirectURL in Safari browser to complete the transaction
})
OPPPaymentProvider *provider = [OPPPaymentProvider paymentProviderWithMode:providerMode];
[provider submitTransaction:transaction completionHandler:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) {
// Open transaction.redirectURL in Safari browser to complete the transaction
}];
3. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.
Ready-to-Use UI
When you use our ready-to-use UI, everything works out-of-box. Just set PIX_VA payment brand and shopper result url in the Checkout Settings class and you are done. Proceed with the presenting checkout as for standard transaction.
Set<String> paymentBrands = new LinkedHashSet<String>();
paymentBrands.add("PIX_VA");
CheckoutSettings checkoutSettings = new CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST);
val paymentBrands = hashSetOf("PIX_VA")
val checkoutSettings = CheckoutSettings(checkoutId, paymentBrands, Connect.ProviderMode.TEST)
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 PIX_VA, which are as follows:
1. Create PIX_VA payment param
Use checkoutId, document type and document Id to create PIX_VA payment params. You may use id card, passport or tax statement number as document id.
PixVaPaymentParams paymentParams = new PixVaPaymentParams(
@NonNull String checkoutId,
@Nullable IdentificationDocType identificationDocType, // IdentificationDocType is Enum values can be (ID_CARD , PASSPORT , TAXSTATEMENT)
@Nullable String identificationDocId);
paymentParams.setShopperResultUrl("com.companyname.appname.payments://result");
val paymentParams = PixVaPaymentParams(
checkoutId,
identificationDocType,// IdentificationDocType is Enum values are(ID_CARD , PASSPORT , TAXSTATEMENT)
identificationDocId
)
paymentParams.shopperResultUrl = "com.companyname.appname.payments://result"
2. Submit transaction
Create a 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)
NOTE: To learn more about shopper result url refer to Asynchronous Payments guide.
3. Implement ITransactionListener
Now, let the class implement the ITransactionListener interface. Implement the following ITransactionListener methods:
Open redirect url and handle the final redirect
You can open this redirect url in your webView present in fragment/activity.
@Override
public void transactionCompleted(Transaction transaction) {
if ("PIX_VA".equals(transaction.getPaymentParams().getPaymentBrand())){
// open this redirectUrl in webview , which should be present in fragment/activity of in app
String redirectUrl = transaction.getRedirectUrl();
} else {
// code for other brands
}
}
@Override
public void transactionFailed(@NonNull Transaction transaction, @NonNull PaymentError error) {
// show error message
}
override fun transactionCompleted(transaction: Transaction) {
if ("PIX_VA" == transaction.paymentParams.paymentBrand) {
// open this redirectUrl in webview , which should be present in fragment/activity of in app
val redirectUrl = transaction.getRedirectUrl
} else {
// code for other brands
}
}
override fun transactionFailed(transaction: Transaction, error: PaymentError) {
// show error message
}
4. Get the payment status
Finally your app should request the payment status from your server.
For more details you can refer to this document.