Updated 21 February 2020
SaveWeaccept payment gateway accepts mastercard and visa.
Dependency
Add following dependency for weaccept-
1 2 3 |
implementation 'com.paymob:acceptsdk:1.0.7' implementation 'com.android.volley:volley:1.1.1' implementation 'morxander.editcard:EditCard:1.0.1' |
Also add following url under project build gradle file.
1 2 3 4 5 6 7 8 9 10 11 |
android{ .... allprojects { repositories { mavenCentral() jcenter() maven { url "https://dl.bintray.com/paymobsolutions/paymob_accept_sdk" } } } ... } |
Go to your activity and create a button by clicking on this you can open sdk.Pass your actual paymentKey.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
public class MainActivity{ Button weAcceptBtn static final int ACCEPT_PAYMENT_REQUEST = 10; // Replace this with your actual payment key final String paymentKey = "your_payment_key"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); weAcceptBtn = findViewById(R.id.weAcceptBtn); weAcceptBtn.setOnClickListener(this); } @Override public void onClick(View v) { startPaymentActivity(true); } } |
In startPaymentActivity() method you can send true or false . If you want to show save card default “on” then send true or if you don’t want then you can send false.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
private void startPaymentActivity(Boolean showSaveCard) { Intent pay_intent = new Intent(this, PayActivity.class); pay_intent.putExtra(PayActivityIntentKeys.FIRST_NAME, "first_name"); pay_intent.putExtra(PayActivityIntentKeys.LAST_NAME, "last_name"); pay_intent.putExtra(PayActivityIntentKeys.BUILDING, "1"); pay_intent.putExtra(PayActivityIntentKeys.FLOOR, "1"); pay_intent.putExtra(PayActivityIntentKeys.APARTMENT, "1"); pay_intent.putExtra(PayActivityIntentKeys.CITY, "Delhi"); pay_intent.putExtra(PayActivityIntentKeys.STATE, "Delhi"); pay_intent.putExtra(PayActivityIntentKeys.COUNTRY, "India"); pay_intent.putExtra(PayActivityIntentKeys.EMAIL, "email@gmail.com"); pay_intent.putExtra(PayActivityIntentKeys.PHONE_NUMBER, "2345678"); pay_intent.putExtra(PayActivityIntentKeys.POSTAL_CODE, "1234"); pay_intent.putExtra(PayActivityIntentKeys.PAYMENT_KEY, paymentKey); pay_intent.putExtra(PayActivityIntentKeys.THREE_D_SECURE_ACTIVITY_TITLE, "Verification"); pay_intent.putExtra(PayActivityIntentKeys.SAVE_CARD_DEFAULT, true); pay_intent.putExtra(PayActivityIntentKeys.SHOW_ALERTS, showSaveCard); pay_intent.putExtra(PayActivityIntentKeys.SHOW_SAVE_CARD, showSaveCard); pay_intent.putExtra(PayActivityIntentKeys.THEME_COLOR, 0x8033B5E5); startActivityForResult(pay_intent, ACCEPT_PAYMENT_REQUEST); } |
Pass the correct values for billing data keys and paymentKey,
Send “Verification” in PayActivityIntentKeys.THREE_D_SECURE_ACTIVITY_TITLE for 3D security reason.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Bundle extras = data.getExtras(); if (requestCode == ACCEPT_PAYMENT_REQUEST) { if (resultCode == IntentConstants.USER_CANCELED) { // User canceled and did no payment request was fired ToastMaker.displayShortToast(this, "User canceled!!"); } else if (resultCode == IntentConstants.MISSING_ARGUMENT) { // You forgot to pass an important key-value pair in the intent's extras ToastMaker.displayShortToast(this, "Missing Argument == " + extras.getString(IntentConstants.MISSING_ARGUMENT_VALUE)); } else if (resultCode == IntentConstants.TRANSACTION_ERROR) { // An error occurred while handling an API's response ToastMaker.displayShortToast(this, "Reason == " + extras.getString(IntentConstants.TRANSACTION_ERROR_REASON)); } else if (resultCode == IntentConstants.TRANSACTION_REJECTED) { // User attempted to pay but their transaction was rejected // Use the static keys declared in PayResponseKeys to extract the fields you want ToastMaker.displayShortToast(this, extras.getString(PayResponseKeys.DATA_MESSAGE)); } else if (resultCode == IntentConstants.TRANSACTION_REJECTED_PARSING_ISSUE) { // User attempted to pay but their transaction was rejected. An error occured while reading the returned JSON ToastMaker.displayShortToast(this, extras.getString(IntentConstants.RAW_PAY_RESPONSE)); } else if (resultCode == IntentConstants.TRANSACTION_SUCCESSFUL) { // User finished their payment successfully // Use the static keys declared in PayResponseKeys to extract the fields you want ToastMaker.displayShortToast(this, extras.getString(PayResponseKeys.DATA_MESSAGE)); } else if (resultCode == IntentConstants.TRANSACTION_SUCCESSFUL_PARSING_ISSUE) { // User finished their payment successfully. An error occured while reading the returned JSON. ToastMaker.displayShortToast(this, "TRANSACTION_SUCCESSFUL - Parsing Issue"); // ToastMaker.displayShortToast(this, extras.getString(IntentConstants.RAW_PAY_RESPONSE)); } else if (resultCode == IntentConstants.TRANSACTION_SUCCESSFUL_CARD_SAVED) { // User finished their payment successfully and card was saved. // Use the static keys declared in PayResponseKeys to extract the fields you want // Use the static keys declared in SaveCardResponseKeys to extract the fields you want ToastMaker.displayShortToast(this, "Token == " + extras.getString(SaveCardResponseKeys.TOKEN)); } else if (resultCode == IntentConstants.USER_CANCELED_3D_SECURE_VERIFICATION) { ToastMaker.displayShortToast(this, "User canceled 3-d scure verification!!"); // Note that a payment process was attempted. You can extract the original returned values // Use the static keys declared in PayResponseKeys to extract the fields you want ToastMaker.displayShortToast(this, extras.getString(PayResponseKeys.PENDING)); } else if (resultCode == IntentConstants.USER_CANCELED_3D_SECURE_VERIFICATION_PARSING_ISSUE) { ToastMaker.displayShortToast(this, "User canceled 3-d scure verification - Parsing Issue!!"); // Note that a payment process was attempted. // User finished their payment successfully. An error occured while reading the returned JSON. ToastMaker.displayShortToast(this, extras.getString(IntentConstants.RAW_PAY_RESPONSE)); } } } |
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.