کلیدستان

نسخه‌ی کامل: راهنمایی در مورد پرداخت درون برنامه ای اول مارکت
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام دوستان کسی میتونه کمکم کنه در این مورد ؟؟
کسی میتونه کد هاشو بصورت خلاصه بزاره
با تشکر
سلام

پرداخت درون برنامه اي تقريبا در تمامي ماركت ها به يكصورت هستش
چون همشون از كلاس هاي اماده گوگل استفاده ميكنن ( با كمي تغييرات براي ماركت و سرور هاي خودشون)

شما كاركردن با يكيش رو بلد باشي بقيه رو سريع ياد ميگيري ( مكانيزم پرداخت و خريد يكي هستش)
سلام من از مستندات یه مشت کر برداشتم و درون برنامه اضافه کردم 
پرداخترو کامل انجام میده ولی توی نتیجه چه موفقیت آمیز باشه چه نباشه اون پرداخت فقط یه دستور رو اجرا میکنه 


{complain("Error purchasing: " + result);}



اینم کد هایی که نوشتم 
دوستان کسی هست راهنمایی کنه 


کد پی‌اچ‌پی:
       String base64EncodedPublicKey "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkX7LsKn+bahjhhl;4xS9ZZ+xV04 +ezak4pPc3vSf6wQJH0n/+Mwif53IsLm/ydgwqeszM385rydRbUAR1GSMuVFpZ7m QHIs2pzz4+ALI7TOn8B4hGNdZv+neLmjIXYLBrv0Q7B1KcbD4PeaZm4ugnYaAIap VDZOcOasQfEYvUvfr9SZRCKlvj1O+tWhLP4SK/zXVbbOgS3SuHpZLfaifgVsIylo 9gmqzbd4sbsVum3Xb32PUq6bTeoTFazIuxGqSfkuCtFpWwmwP9do0TP6AlHBALPb R2yO8UaHUfSSHtXokoR0yePQD/wjU6WzAmljXyKshE7uH5joFpaeQQFzofNtvyd0 uQIDAQAB";

// You can find it in your Avval market console.
// It is recommended to add more security than just pasting it in your source code;
 
       mHelper = new IabHelper(thisbase64EncodedPublicKey);

 
       Log.d(TAG"Starting setup.");
 
       mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
 
           public void onIabSetupFinished(IabResult result) {
 
               Log.d(TAG"Setup finished.");

 
               if (!result.isSuccess()) {
 
                   // Oh noes, there was a problem.
 
                   Log.d(TAG"Problem setting up In-app Billing: " result);
 
               }
 
               // Hooray, IAB is fully set up!
 
               mHelper.queryInventoryAsync(mGotInventoryListener);
 
           }
 
       });

btn1.setOnClickListener(new View.OnClickListener() {
 
   @Override
    public void onClick
(View v) {
 
       mHelper.launchPurchaseFlow(pay.thisSKU_PREMIUMRC_REQUEST,
 
               mPurchaseFinishedListener"payload-string");
 
   }
});

 
   }





 
   IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
 
       @Override

        public void onQueryInventoryFinished
(IabResult resultInventory inventory) {
 
           Log.d(TAG"Query inventory finished.");
rt.stop();
 
           // Have we been disposed of in the meantime If so, quit.
 
           if (mHelper == null) return;

 
           // Is it a failure
 
           if (result.isFailure()) {
 
               complain("Failed to query inventory: " result);
 
               return;
 
           }

 
           Log.d(TAG"Query inventory was successful.");

 
      /*
        * Check for items we own. Notice that for each purchase, we check
        * the developer payload to see if it's correct! See
        * verifyDeveloperPayload().
        */

 
           // Do we have the premium upgrade
 
           Purchase premiumPurchase inventory.getPurchase(SKU_PREMIUM);
 
           mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));



 
           Log.d(TAG"Initial inventory query finished; enabling main UI.");
 
       }
 
   };

 
   boolean verifyDeveloperPayload(Purchase p) {
 
       String payload p.getDeveloperPayload();

 
       /*
         * TODO: verify that the developer payload of the purchase is correct. It will be
         * the same one that you sent when initiating the purchase.
         *
         * WARNING: Locally generating a random string when starting a purchase and
         * verifying it here might seem like a good approach, but this will fail in the
         * case where the user purchases an item on one device and then uses your app on
         * a different device, because on the other device you will not have access to the
         * random string you originally generated.
         *
         * So a good developer payload has these characteristics:
         *
         * 1. If two different users purchase an item, the payload is different between them,
         *    so that one user's purchase can't be replayed to another user.
         *
         * 2. The payload must be such that you can verify it even when the app wasn't the
         *    one who initiated the purchase flow (so that items purchased by the user on
         *    one device work on other devices owned by the user).
         *
         * Using your own server to store and verify developer payloads across app
         * installations is recommended.
         */

 
       return true;
 
   }


 
   // Callback for when a purchase is finished
 
   public IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
 
       public void onIabPurchaseFinished(IabResult resultPurchase purchase) {
 
           Log.d(TAG"Purchase finished: " result ", purchase: " purchase);

 
           // if we were disposed of in the meantime, quit.
 
           if (mHelper == null) return;

 
           if (result.isFailure()) {
 
               complain("Error purchasing: " result);
 
               Toast.makeText(pay.this"33033"Toast.LENGTH_SHORT).show();
 
               return;
 
           }
 
           if (!verifyDeveloperPayload(purchase)) {
 
               complain("Error purchasing. Authenticity verification failed.");
 
               Toast.makeText(pay.this"2222"Toast.LENGTH_SHORT).show();
 
               return;
 
           }

 
           Log.d(TAG"Purchase successful.");
 
           Toast.makeText(pay.this"001"Toast.LENGTH_SHORT).show();
 
       }
 
   };

 
   @Override
    protected void onActivityResult
(int requestCodeint resultCodeIntent data) {
 
       Log.d(TAG"onActivityResult(" requestCode "," resultCode "," data);
 
       if (mHelper == null) return;

 
       // Pass on the activity result to the helper for handling
 
       if (!mHelper.handleActivityResult(requestCoderesultCodedata)) {
 
           // not handled, so handle it ourselves (here's where you'd
 
           // perform any handling of activity results not related to in-app
 
           // billing...
 
           super.onActivityResult(requestCoderesultCodedata);
 
       }
 
       else {
 
           Log.d(TAG"onActivityResult handled by IABUtil.");
 
       }
 
   }
 
   void complain(String message) {
 
       Log.e(TAG"**** TrivialDrive Error: " message);
 
       alert("Error: " message);
 
   }

 
   void alert(String message) {
 
       AlertDialog.Builder bld = new AlertDialog.Builder(this);
 
       bld.setMessage(message);
 
       bld.setNeutralButton("OK"null);
 
       Log.d(TAG"Showing alert dialog: " message);
 
       bld.create().show();
 
   }

 
   void saveData() {

 
       /*
         * WARNING: on a real application, we recommend you save data in a secure way to
         * prevent tampering. For simplicity in this sample, we simply store the data using a
         * SharedPreferences.
         */

 
       SharedPreferences.Editor spe getPreferences(MODE_PRIVATE).edit();

 
       spe.apply();

 
   }

 
   void loadData() {
 
       SharedPreferences sp getPreferences(MODE_PRIVATE);


 
   }
 
   @Override
    public void onDestroy
() {
 
       super.onDestroy();
 
       // very important:
 
       Log.d(TAG"Destroying helper.");
 
       if (mHelper != null) {
 
           mHelper.dispose();
 
           mHelper null;
 
       }
 
   }


ن یه مشت کد از مستندات پیدا کردم و نوشتم 
پرداخت رو انجام میده ولی  چه در صورت موفقیت در پرداخت چه در عدم موفقیت فقط یه دستور رو اجرا میکنه