最近のアクセス:
PayPal の繰り返し決済

サブスクリプション (例: 月ごとの決済) を必要とする製品を販売する場合、繰り返し決済を使用します。
まず、プランを設定する必要があります。プランとはユーザーの決済内容の明細です。
例: プレミアムアカウント、月額 15 ドル。
設定するには、PayPal でプランを作成して有効にする必要があります。
CreateBillingPlan SDT と payment_definitions を使用してプランを設定し、CreateBillingPlanAPI プロシージャーを使用してそのプランを作成します。
正しく作成したら (エラーコードが 0 であることを確認)、API の応答を CreateBillingPlanResponse SDT にマッピングし、ActivateBillingPlan プロシージャーとプランの Id を使用して計画を有効にします。
&BaseURL = &HttpRequest.BaseUrl

&CreateBillingPlan.name = "プラン 1"
&CreateBillingPlan.description = "プラン 1"
&CreateBillingPlan.type = PlanType.INFINITE

&CreateBillingPlan.merchant_preferences.return_url = &BaseURL + CancelAgreement.Link()
&CreateBillingPlan.merchant_preferences.cancel_url = &BaseURL + ExecuteAgreement.Link()
&CreateBillingPlan.merchant_preferences.auto_bill_amount = "no"
&CreateBillingPlan.merchant_preferences.max_fail_attempts = "0" 
&CreateBillingPlan.merchant_preferences.initial_fail_amount_action = "CONTINUE"


&payment_definitions.amount.value = "50"
&payment_definitions.amount.currency = "USD"
&payment_definitions.frequency_interval = "1"
&payment_definitions.frequency = "日"
&payment_definitions.cycles = "0"
&payment_definitions.name = "発送"
&payment_definitions.type = "通常"

&CreateBillingPlan.payment_definitions.Add(&payment_definitions)

CreateBillingPlanAPI(&CreateBillingPlan.ToJson(),&APIResponse,&ErrorCode)

if &ErrorCode = 0
    &CreateBillingPlanResponse.FromJson(&APIResponse)
    &planId = &CreateBillingPlanResponse.id
    ActivateBillingPlan(&planId,&APIResponse,&ErrorCode)
endif

if &ErrorCode = 0
    Msg("成功",status)
endif
請求に同意することにより、購入者とプランとの間に関係が作られます。
決済と同様に、同意を作成し、ユーザーに認証と同意を実行してもらう必要があります。
同意を設定するには、CreateBillingAgreement SDT と CreateBillingAgreementAPI プロシージャーを使用します。CreateBillingAgreementResponse SDT を使用して応答を処理し、ユーザーを PayPal の Web サイトにリダイレクトします。
注: 同意が有効になるまでに最短で 24 時間かかります (必要に応じて時間を長くすることもできます)。
ユーザーの認証後、PayPal が成功の URL を呼び出し、パラメーターとしてトークンを送信します。そのトークンを使用して同意を実行します。事前に指定した時間が過ぎると有効になります (最短で 24 時間)。
Success WebPanel は次のようになります:
Event Start
    Do 'ParseString'
    ExecuteAgreementAPI(&token,&APIResponse,&ErrorCode)
    if &ErrorCode = 0
        Msg("同意成功")
    endif
EndEvent

Sub 'ParseString'
    &Regex = "="
    &Parms = &httpRequest.QueryString
    &Matches = &Parms.SplitRegEx(&Regex)
    &token = &Matches.Item(2)
EndSub
 
 





サブページ
Created: 18/10/29 01:07 by Admin Last update: 21/10/28 23:30 by Admin
カテゴリ
Powered by GXwiki 3.0