- Get Started
- Guides
- Integrations
- References
- API Reference
- Basic Payment
- Forex
- Authentication
- Card Account
- Apple Pay
- Virtual Account
- Bank Account
- Token Account
- Customer
- Billing Address
- Merchant Billing Address
- Shipping Address
- Merchant Shipping Address
- Corporate
- Sender
- Recipient
- Merchant
- Marketplace & Cart
- Airline
- Lodging
- Passenger
- Tokenization
- Recurring Migration
- 3D Secure
- Custom Parameters
- Async Payments
- Webhook notifications
- Job
- Risk
- Point of Sale
- Response Parameters
- Card On File
- Chargeback
- Result Codes
- Payment Methods
- Transaction Flows
- Regression Testing
- Data Retention Policy
- Release Notes
- API Reference
- Support
YooKassa
Follow this guide to integrate payments with YooKassa into your app.
NOTE: Ready-to-use UI doesn't support this payment method at the moment.
iOS
Android
SDK & Your Own UI
Please follow YooKassa documentation YooKassa documentation to integrate payment form into your app and obtain payment token. Once you have a payment token, you can initiate transaction with Mobile SDK.
-
Create payment parameters
Create
YooKassaPaymentParams
OPPYooKassaPaymentParams
with received payment token.NSError *error = nil; OPPYooKassaPaymentParams *params = [OPPYooKassaPaymentParams yooKassaPaymentParamsWithCheckoutID:checkoutID paymentToken:paymentToken error:&error]; // Set shopper result URL params.shopperResultURL = @"com.companyname.appname.payments://result";
do { let params = try OPPYooKassaPaymentParams.init(checkoutID: checkoutID, paymentToken: paymentToken) // Set shopper result URL params.shopperResultURL = "com.companyname.appname.payments://result" } catch let error as NSError { // See error.code (OPPErrorCode) and error.localizedDescription to identify the reason of failure }
PaymentParams paymentParams = new YooKassaPaymentParams(checkoutId, paymentToken); paymentParams.setShopperResultUrl("companyname://result");
val paymentParams: PaymentParams = YooKassaPaymentParams(checkoutId, paymentToken) paymentParams.shopperResultUrl = "companyname://result"
NOTE: To learn more about shopper result URL refer to Asynchronous payments guide.
The
shopperResultUrl
will be sent to YooKassa asreturn_url
in the payment creation request. -
Submit transaction
OPPTransaction *transaction = [OPPTransaction transactionWithPaymentParams:params]; [self.provider submitTransaction:transaction completionHandler:^(OPPTransaction * _Nonnull transaction, NSError * _Nullable error) { if (error) { // Handle the error. } else { // retrieve YooKassa info from transaction, it contains status, confirmation url and callback url OPPYooKassaInfo *yooKassaInfo = transaction.yooKassaInfo; switch (yooKassaInfo.status) { case OPPYooKassaStatusSucceeded: // request payment status break; case OPPYooKassaStatusWaitingForCapture: // no confirmation required, request payment status break; case OPPYooKassaStatusPending: // get confirmation url from OPPYooKassaInfo and redirect user to confirm the payment break; case OPPYooKassaStatusCanceled: // handle canceled status break; case OPPYooKassaStatusUndefined: // handle unknown status break; } } } }];
let transaction = OPPTransaction(paymentParams: params) provider.submitTransaction(transaction) { (transaction, error) in guard let transaction = transaction else { // Handle invalid transaction, check error return } // retrieve YooKassa info from transaction, it contains status, confirmation url and callback url let yooKassaInfo = transaction.yooKassaInfo switch yooKassaInfo.status { case .succeeded: // request payment status break case .waitingForCapture: // no confirmation required, request payment status break case .pending: // get confirmation url from OPPYooKassaInfo and redirect user to confirm the payment break case .canceled: // handle canceled status break case .undefined: // handle unknown status break } }
OppPaymentProvider paymentProvider = new OppPaymentProvider(MainActivity.this, Connect.ProviderMode.TEST); Transaction transaction = new Transaction(paymentParams); paymentProvider.submitTransaction(transaction, MainActivity.this);
val paymentProvider = OppPaymentProvider(this@MainActivity, Connect.ProviderMode.TEST) val transaction = Transaction(paymentParams) paymentProvider.submitTransaction(transaction, this@MainActivity)
-
Check transaction result
Implement the confirmation scenario (only for PENDING)
Use the confirmation url from
OPPYooKassaInfo
and redirect user to confirm the payment.YooKassa SDK provides its own implementation to confirm the payment. If you are going to use this way follow these steps:
- Save tokenization module.
Extend your view controller with Swift implementation.
self.tokenizationViewController = TokenizationAssembly.makeModule(inputData: inputData, moduleOutput: self) present(self.tokenizationViewController, animated: true, completion: nil)
- Do not dismiss the tokenization module after receiving the token.
Extend your view controller with Swift implementation.
func tokenizationModule(_ module: TokenizationModuleInput, didTokenize token: Tokens, paymentMethodType: PaymentMethodType) { // Use token to create OPPYooKassaPaymentParams and send transaction. }
- Start the payment confirmation, if it's required.
Extend your view controller with Swift implementation.
self.tokenizationViewController.startConfirmationProcess( confirmationUrl: confirmationUrl, paymentMethodType: paymentMethodType )
- After successful confirmation, the method will be called.
Extend your view controller with Swift implementation.
func didSuccessfullyConfirmation(paymentMethodType: PaymentMethodType) { DispatchQueue.main.async { [weak self] in guard let self = self else { return } // Now close tokenization module self.dismiss(animated: true) } }
class MyActivity extends AppCompatActivity implements ITransactionListener { ... @Override public void transactionCompleted(Transaction transaction) { // retrieve YooKassa info from transaction, it contains status, confirmation url and callback url YooKassaInfo yooKassaInfo = transaction.getYooKassaInfo(); switch (yooKassaInfo.getStatus()) { case SUCCEEDED: case WAITING_FOR_CAPTURE: // no confirmation required, request payment status break; case PENDING: // get confirmation url from YooKassaInfo and redirect user to confirm the payment break; case CANCELED: // handle canceled status break; case UNDEFINED: // handle unknown status break; } } @Override public void transactionFailed(Transaction transaction, PaymentError paymentError) { // handle payment error } }
class MainActivity : AppCompatActivity(), ITransactionListener { ... override fun transactionCompleted(transaction: Transaction) { // retrieve YooKassa info from transaction, it contains status, confirmation url and callback url val yooKassaInfo = transaction.yooKassaInfo when (yooKassaInfo!!.status) { YooKassaStatus.SUCCEEDED, YooKassaStatus.WAITING_FOR_CAPTURE -> { // no confirmation required, request payment status } YooKassaStatus.PENDING -> { // get confirmation url from YooKassaInfo and redirect user to confirm the payment } YooKassaStatus.CANCELED -> { // handle canceled status } YooKassaStatus.UNDEFINED -> { // handle unknown status } } } override fun transactionFailed(transaction: Transaction, paymentError: PaymentError) { // handle payment error } }
YooKassa SDK provides its own Activity for 3DS processing. It can be used in this case. If you're using this Activity don't set
PaymentParameters.customReturnUrl
duringCheckout.createTokenizeIntent()
call.class MyActivity extends AppCompatActivity implements ITransactionListener { ... void start3DS(YooKassaInfo yooKassaInfo) { Intent intent = Checkout.createConfirmationIntent( this, yooKassaInfo.getConfiramtionUrl(), PaymentMethodType.BANK_CARD ); startActivityForResult(intent, 1); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { switch (resultCode) { case RESULT_OK: // 3ds completed break; case RESULT_CANCELED: // 3ds canceled by user break; case Checkout.RESULT_ERROR: // there was an error during 3ds // more details in data // data.getIntExtra(Checkout.EXTRA_ERROR_CODE) - error code from WebViewClient.ERROR_* or Checkout.ERROR_NOT_HTTPS_URL // data.getStringExtra(Checkout.EXTRA_ERROR_DESCRIPTION) - error description (might be null) // data.getStringExtra(Checkout.EXTRA_ERROR_FAILING_URL) - url which caused an error (might be null) break; } } } }
class MainActivity : AppCompatActivity(), ITransactionListener { ... fun start3DS(yooKassaInfo : YooKassaInfo) { val intent = Checkout.createConfirmationIntent( this@MainActivity, yooKassaInfo.confirmationUrl.toString(), PaymentMethodType.BANK_CARD ) startActivityForResult(intent, 1); } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == 1) { when (resultCode) { RESULT_OK -> { // 3ds completed } RESULT_CANCELED -> { // 3ds canceled by user } Checkout.RESULT_ERROR -> { // there was an error during 3ds // more details in data // data.getIntExtra(Checkout.EXTRA_ERROR_CODE) - error code from WebViewClient.ERROR_* or Checkout.ERROR_NOT_HTTPS_URL // data.getStringExtra(Checkout.EXTRA_ERROR_DESCRIPTION) - error description (might be null) // data.getStringExtra(Checkout.EXTRA_ERROR_FAILING_URL) - url which caused an error (might be null) } } } } }
- Save tokenization module.
-
Finalize transaction (only for PENDING)
Once confirmation is done you should send a GET request to the callbackUrl to finalize pending transaction.
-
Request payment status
To get the status of the transaction, you should make a payment status request.