Code Monkey home page Code Monkey logo

zarinpal-android-sample's Introduction

Zarinpal Android Sample

Library to use ZarinPal payment service in android apps

This library lets android developers have in-app-purchase using ZarinPal service.

##How to use ###Prepare project:

  1. Download and add this jar file into your project as a library:
  2. Copy jar file in project-directory/app/libs/
  3. Right click on file in Android Studio and click on Add as library
  4. Add our payment Activity to your project manifest file as shown below:
<application>
  .
  .
  .
     <activity android:name="ir.moslem_deris.apps.zarinpal.PaymentActivity"/>
  .
  .
  .
</application>
  1. Add Internet permission to your manifest file (for android 5 and below):
  <uses-permission android:name="android.permission.INTERNET"/>
  1. Add okHttp library to your project dependencies:

compile 'com.squareup.okhttp3:okhttp:3.5.0'

###How to code: Create a Payment object and put the data you want in it like the code below:

Payment payment = new PaymentBuilder()
                .setMerchantID("4ff2f25a-82c8-45eb-b540-4c5b5ee8aeb5")  //  This is an example, put your own merchantID here.
                .setAmount(100)                                         //  Amount in Toman
                .setDescription("put payment description here")
                .setEmail("[email protected]")                     //  This field is not necessary.
                .setMobile("09123456789")                               //  This field is not necessary.
                .create();

Everywhere you want to run the pay method just call ZarinPal.pay(x, y, z);

x: Current activity, just passthis

y: your Payment object

z: OnPaymentListener

###Example code

ZarinPal.pay(this, payment, new OnPaymentListener() {
            @Override
            public void onSuccess(String refID) {
                Log.wtf("TAG", "HOOOORAAAY!!! your refID is: " + refID);
            }

            @Override
            public void onFailure(ZarinPalError error) {
                String errorMessage = "";
                switch (error){
                    case INVALID_PAYMENT: errorMessage = "پرداخت تایید نشد"; break;
                    case USER_CANCELED:   errorMessage = "پرداخت توسط کاربر متوقف شد"; break;
                    case NOT_ENOUGH_DATA: errorMessage = "اطلاعات پرداخت کافی نیست"; break;
                    case UNKNOWN:         errorMessage = "خطای ناشناخته"; break;
                }
                Log.wtf("TAG", "ERROR: " + errorMessage);
            }
        });

[حمایت مالی از سازنده پلاگین] (https://2nate.com/pays/create/user/1637) alt text

zarinpal-android-sample's People

Contributors

mderis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

ihamex

zarinpal-android-sample's Issues

کد Authority

در این روش چطوری میشه به کد auhority دسترسی داشت؟
ممنون

خطای ناشناخته

من بر اساس اموزشی که نوشته اید و سمپل پروژه ی شما فایل رو اد و کلاسی ایجاد کردم و به درستی فایل اجرا میشه
فقط در زمان پرداخت تست با کانفیگ شما و یا خودم فرق نمی کنه
ارور ی که برمی گردونه خطای ناشناخته است آیا این سرویس از کار افتاده و باید از سرویس پی اچ پی استفاده کنم؟؟

خطا در کامپایل

با سلام
تمام مراحلی که گفته بودید رو انجام دادم ولی در زمان کامپایل از کتاخونه زیر خطا میگیر
compile 'com.squareup.okhttp3:okhttp:3.5.0'
آخرین ورژن رو هم گرفتم
compile 'com.squareup.okhttp3:okhttp:3.6.0'
ولی بازم خطا داره
ممنون میشم اگه لطفا راهنمایی کنید

حذف توست بعد از پرداخت

سلام. بعد از پرداخت موفق یا ناموفق یک توست نشون میده (درحال تکمیل خرید...). چطور میتونم اون توست رو بردارم؟

خطای ناشناخته

سلام و عرض خسته نباشید.
من هم مثل دوستی که قبلا سوال پرسیدن با همین خطا مواجه میشم .دسترسی به اینترنت هم دادم. حتی پروژه خودتونم
اجرا کنیم همین خطارو میده .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.