├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.MD ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zarinpal │ │ └── ewallets │ │ └── purchasesdk │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── zarinpal │ │ │ └── ewallets │ │ │ └── purchasesdk │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable │ │ └── img.png │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── zarinpal │ └── ewallets │ └── purchasesdk │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── purchase ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zarinpal │ │ └── ewallets │ │ └── purchase │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── zarinpal │ │ │ └── ewallets │ │ │ └── purchase │ │ │ ├── HttpQueue.java │ │ │ ├── HttpRequest.java │ │ │ ├── HttpRequestListener.java │ │ │ ├── OnCallbackRequestPaymentListener.java │ │ │ ├── OnCallbackVerificationPaymentListener.java │ │ │ ├── Payment.java │ │ │ ├── PaymentRequest.java │ │ │ ├── SandboxPaymentRequest.java │ │ │ ├── VerificationPayment.java │ │ │ └── ZarinPal.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── zarinpal │ └── ewallets │ └── purchase │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Android 51 | 52 | 53 | Android > Lint > Correctness 54 | 55 | 56 | Android > Lint > Performance 57 | 58 | 59 | CorrectnessLintAndroid 60 | 61 | 62 | General 63 | 64 | 65 | LintAndroid 66 | 67 | 68 | 69 | 70 | Android 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 82 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # The Repo and Project has been DEPRECATED and Archived please check [Android-SDK](https://github.com/ZarinPal/Android-SDK) 2 | 3 | # ZarinPal Purchase Android SDK 4 | 5 | ZarinPal Payment Requeset SDK on Android Platforms 6 | Simply Request to ZarinPal IPG and Callback Handling 7 | 8 | 9 | ### ZarinPal Flow: 10 | In first step You must initilize of `ZarinPal` by `getPurchase` after that, ZarinPal Ready to Payment. for begining you must create a `PaymentRequest` by `getPaymentRequest`, Now you must set parameters `MerchantID`, `Amount (In Rials)`, `Description` and `CallbackUrl` 11 | 12 | **What is `Payment Request`?** 13 | 14 | Payment Request is require paramaters payment for Indentity in ZarinPal 15 | 16 | **Require Parameters:** 17 | 18 | * Merchant id: An unique ID of your business payment gateway. 19 | * Amount: Amount of Purchase. 20 | * Callback URL: A valid `URI` or `URL` Address for sending result purchase. 21 | * Description: A Content for showing to payer. 22 | 23 | **Optional Parameters:** 24 | 25 | * Mobile: Valid Mobile number of payer. 26 | * Email: Valid Email Address of payer. 27 | 28 | You send a PaymentRequest for ZarinPal with parameters MerchantID, Amount (In Rials), Description and CallbackUrl . Then ZarinPal will reply to you with a unique purchase ID (Authority). 29 | Then with the Authority in Hand, You call `startPayment` method and ZarinPal in response will direct you to a payment gateway if the purchase ID is valid and after completing the purchase , Zarinpal send Purchase Result to CallbackUrl. 30 | After completing the purchase, you can send a `verificationPayment` request if it is successful, and ZarinPal will send you a RefID, which represents the transaction ID, in case of success. 31 | 32 | for verifty purchase you must set `getIntent().getData()` and call `verificationPayment` for verify inner app sure ZarinPal don't recommend to use this method becuase this is not safe. That's better you do verifing flow on your server and notify your app. 33 | 34 | >Note: ZarinPal is not IAB or IAP, ZarinPal JUST provides payment solution. 35 | 36 | 37 | How to use 38 | ========== 39 | 40 | 41 | - Compile ZarinPal In App Purchase SDK: 42 | ```Gradle 43 | implementation 'com.zarinpal:purchase:0.0.10' 44 | ``` 45 | - Internet Access Permission on `AndroidManifest.xml`: 46 | 47 | ```XML 48 | 49 | ``` 50 | - Set Your Application Scheme on `AndroidManifest.xml` to Callback for inner handling in App: 51 | ```XML 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | ``` 61 | >Note: If You want handle and checking of verification your Payment on Your sever you must set your server address (aka `URL`) by `setCallbackURL` and no need to do the above step. 62 | 63 | ### Example For Payment Request: 64 | ```Java 65 | ZarinPal purchase = ZarinPal.getPurchase(this); 66 | PaymentRequest payment = ZarinPal.getPaymentRequest(); 67 | //If you will test on our sandbox, you can use it: 68 | PaymentRequest payment = ZarinPal.getSandboxPaymentRequest(); 69 | 70 | 71 | 72 | payment.setMerchantID("71c705f8-bd37-11e6-aa0c-000c295eb8fc"); 73 | payment.setAmount(100); 74 | payment.isZarinGateEnable(true); // If you actived `ZarinGate`, can handle payment by `ZarinGate` 75 | payment.setDescription("In App Purchase Test SDK"); 76 | payment.setCallbackURL("yourapp://app"); /* Your App Scheme */ 77 | payment.setMobile("09355106005"); /* Optional Parameters */ 78 | payment.setEmail("imannamix@gmail.com"); /* Optional Parameters */ 79 | 80 | 81 | purchase.startPayment(payment, new OnCallbackRequestPaymentListener() { 82 | @Override 83 | public void onCallbackResultPaymentRequest(int status, String authority, Uri paymentGatewayUri, Intent intent) { 84 | 85 | 86 | if (status == 100) { 87 | /* 88 | When Status is 100 Open Zarinpal PG on Browser 89 | */ 90 | startActivity(intent); 91 | } else { 92 | Toast.makeText(getApplicationContext(), "Your Payment Failure :(", Toast.LENGTH_LONG).show(); 93 | } 94 | 95 | } 96 | }); 97 | ``` 98 | 99 | 100 | ### Example For Callback Handler: 101 | ```Java 102 | /** 103 | * When User Return to Application From IPG on Browser 104 | */ 105 | Uri data = getIntent().getData(); 106 | ZarinPal.getPurchase(this).verificationPayment(data, new OnCallbackVerificationPaymentListener() { 107 | @Override 108 | public void onCallbackResultVerificationPayment(boolean isPaymentSuccess, String refID, PaymentRequest paymentRequest) { 109 | 110 | 111 | if (isPaymentSuccess) { 112 | /* When Payment Request is Success :) */ 113 | String message = "Your Payment is Success :) " + refID; 114 | Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); 115 | } else { 116 | /* When Payment Request is Failure :) */ 117 | String message = "Your Payment is Failure :("; 118 | Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); 119 | } 120 | 121 | 122 | } 123 | }); 124 | 125 | ``` 126 | 127 | ### New Options: 128 | 129 | * Support ZarinGate in 0.0.4 Version 130 | * Implemented SandBox Payment in 0.0.8 Version 131 | * `ZarinGate` is Optional attribute in 0.0.10 Version 132 | 133 | 134 | 135 | Developed By 136 | ============ 137 | 138 | The Product developed by ZarinPal Team also You can Communicate and open issue 139 | >Note: This version is open source then you can open pull request and we check it, If project 140 | need to your change, We will certainly merge it. 141 | 142 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion '26.0.3' 6 | 7 | lintOptions { 8 | abortOnError false 9 | } 10 | defaultConfig { 11 | multiDexEnabled true 12 | } 13 | 14 | dexOptions { 15 | javaMaxHeapSize "4g" 16 | } 17 | defaultConfig { 18 | applicationId "com.zarinpal.ewallets.purchasesdk" 19 | minSdkVersion 15 20 | targetSdkVersion 29 21 | versionCode 1 22 | versionName "1.0" 23 | } 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | } 31 | 32 | dependencies { 33 | implementation fileTree(dir: 'libs', include: ['*.jar']) 34 | testImplementation 'junit:junit:4.12' 35 | implementation 'com.android.support:appcompat-v7:28.0.0' 36 | 37 | // implementation 'com.zarinpal:purchase:0.0.9' 38 | 39 | 40 | implementation project (":purchase") 41 | 42 | 43 | 44 | // compile project(path: ':purchase') 45 | } 46 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Library/Android SDK/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zarinpal/ewallets/purchasesdk/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.zarinpal.ewallets.purchasesdk; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/zarinpal/ewallets/purchasesdk/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.zarinpal.ewallets.purchasesdk; 2 | 3 | 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.widget.Button; 11 | 12 | import com.zarinpal.ewallets.purchase.OnCallbackRequestPaymentListener; 13 | import com.zarinpal.ewallets.purchase.OnCallbackVerificationPaymentListener; 14 | import com.zarinpal.ewallets.purchase.PaymentRequest; 15 | import com.zarinpal.ewallets.purchase.ZarinPal; 16 | 17 | 18 | public class MainActivity extends AppCompatActivity { 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | if (getIntent().getData() != null) { 26 | 27 | ZarinPal.getPurchase(this).verificationPayment(getIntent().getData(), new OnCallbackVerificationPaymentListener() { 28 | @Override 29 | public void onCallbackResultVerificationPayment(boolean isPaymentSuccess, String refID, PaymentRequest paymentRequest) { 30 | Log.i("TAG", "onCallbackResultVerificationPayment: " + refID); 31 | } 32 | }); 33 | } 34 | 35 | Button btnPay = (Button) findViewById(R.id.btnPayment); 36 | btnPay.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View view) { 39 | 40 | 41 | PaymentRequest payment = ZarinPal.getSandboxPaymentRequest(); 42 | 43 | 44 | payment.setMerchantID("71c705f8-bd37-11e6-aa0c-000c295eb8fc"); 45 | payment.setAmount(120); 46 | payment.setDescription("In App Purchase Test SDK"); 47 | payment.setCallbackURL("app://app"); 48 | payment.setMobile("09355106005"); 49 | payment.setEmail("imannamix@gmail.com"); 50 | payment.isZarinGateEnable(false); 51 | 52 | 53 | ZarinPal.getPurchase(getApplicationContext()).startPayment(payment, new OnCallbackRequestPaymentListener() { 54 | @Override 55 | public void onCallbackResultPaymentRequest(int status, String authority, Uri paymentGatewayUri, Intent intent) { 56 | 57 | startActivity(intent); 58 | } 59 | }); 60 | 61 | } 62 | }); 63 | 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZarinPal-Lab/Android-SDK-Payment/64889146d04c9d93190d0ee0c32ca7d77d183f55/app/src/main/res/drawable/img.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 18 | 19 |