-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhamrahpay.b4a
128 lines (113 loc) · 5.23 KB
/
hamrahpay.b4a
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Build1=Default,b4a.hamrahpay
File1=paybtn.bal
FileGroup1=Default Group
Group=Default Group
IconFile=
Library1=core
Library2=phone
Library3=json
Library4=reflection
Library5=okhttputils2
Library6=network
Library7=randomaccessfile
Library8=runtimepermissions
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: http://www.basic4ppc.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")~\n~'End of default text.~\n~~\n~AddActivityText(Main,~\n~<intent-filter>~\n~ <action android:name="android.intent.action.VIEW"/>~\n~ <category android:name="android.intent.category.DEFAULT"/>~\n~ <category android:name="android.intent.category.BROWSABLE"/>~\n~ <data android:host="your_b4a_app_unique_id" android:scheme="hamrahpay"/>~\n~</intent-filter> ~\n~)~\n~
Module1=Hamrahpay
Module2=LastPurchaseInfo
Module3=Lastpurachase
Module4=StateManager
NumberOfFiles=1
NumberOfLibraries=8
NumberOfModules=4
Version=8
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: Hamrahpay B4A
#VersionCode: 3
#VersionName: 3
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
' www.Hamrahpay
' HamrahPay Official library for basic4android developers
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim HP As Hamrahpay
End Sub
Sub Globals
Dim product_sku As String
Private rp As RuntimePermissions
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Private pay_btn As Button
Activity.LoadLayout("paybtn")
End Sub
Sub Activity_Resume
If Not(HP.IsInitialized) Then HP.Initialize("your_b4a_app_unique_id",Me)
HP.HamrahPayVerification(Activity.GetStartingIntent)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_Click
End Sub
Sub pay_btn_Click
'------------------- begin of payment codes ----------------------------
If rp.Check(rp.PERMISSION_READ_PHONE_STATE)=True Then
product_sku="hp_55202faf1ddd8901148214" ' کد محصول خود را جایگزین نمایید
HP.pay_request(product_sku)
Else
rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
End If
'------------------ end of payment codes -------------------------------
End Sub
Sub pay_status_Click
If HP.isPayed(product_sku)=True Then
ToastMessageShow("پرداخت انجام شده است",True)
Else
ToastMessageShow("پرداختی انجام نشده است",True)
End If
End Sub
'------------------------------------------------------------------------------
Sub onPaymentSucceed(paycode As String,sku As String)
'کد های فعال سازی برنامه خود را در این قسمت بنویسید
' write your activate code here
HP.MakePayed(product_sku)
ToastMessageShow("نرم افزار شما به نسخه طلایی ارتقاع پیدا کرد." & product_sku,True)
End Sub
'-----------------------------------------------------------------------
' -------------------Permission request result ---------------------------
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = rp.PERMISSION_READ_PHONE_STATE And Result=True Then
HP.pay_request(product_sku)
Else if Permission=rp.PERMISSION_READ_PHONE_STATE And Result=False Then
ToastMessageShow("لطفا برای ادامه ی روند پرداخت سطح دسترسی لازم را به برنامه بدهید",True)
End If
End Sub
'-------------------------------------------------------------------------
Sub lastpurchase_btn_Click
product_sku="hp_55202faf1ddd8901148214" ' کد محصول خود را جایگزین نمایید
HP.RetriveLastPurchaseInfo(product_sku)
End Sub
' ---------------------Last Purchase data -------------------------------
' در صورتی که بخواهید از پرداخت اشتراکی استفاده نمایید اطلاعات آخرین خرید مشتری در این متد آورده میشود
' ----------------------------------------------------------------------
Sub onGetLastPurchaseInfoSucceed(lastPurchase As LastPurchaseInfo)
If lastPurchase.error=False Then
Dim daysAgo As Int = lastPurchase.DaysAgo ' number of days ago of last purchase
Dim purchaseDate As String = lastPurchase.date ' last purchase date
Dim current_date As String =lastPurchase.CurrentDate ' current date
Dim purchaseUnixTimeStamp As String = lastPurchase.unixTimestamp ' current date in unix timestamp format
Dim reserve_id As String = lastPurchase.ReserveID ' reserve id of last purchase
ToastMessageShow("Days Ago: "&daysAgo&" Reserve ID: "&reserve_id,True)
Else
ToastMessageShow(lastPurchase.message,True)
End If
End Sub
Sub JobDone (Job As HttpJob)
HP.JobDone(Job)
End Sub