2014-12-03 33 views
2

我使用Paypal REST API(java)執行定期訂閱。貝寶REST API - 協議是否被取消?

流程是這樣的,它是工作:

  • 我創造了我激活的計劃(OK)
  • 我創建了一個協議(OK)
  • 計劃(OK)
  • 我用審批環節(OK)重定向用戶到貝寶
  • 貝寶重定向用戶返回到我的網站(OK)
  • 我可以執行協議(OK)

我發現作爲買家,我可以登錄paypal並隨時手動取消協議。

問題:

作爲賣家,我可以看到,買家購買後X取消了他在「個人資料>定期付款儀表盤」的協議,但我怎麼可以查詢的代碼這一信息?假設我有協議ID。協議對象內沒有這樣的信息。

請指點我正確的方向。 謝謝

UPDATE:

我的協議對象是這樣的:

{ 
    "id": "I-HLK83FVHB5X2", 
    "description": "item name goes here", 
    "start_date": "2014-12-04T05:00:00Z", 
    "plan": { 
    "payment_definitions": [ 
     { 
     "type": "TRIAL", 
     "frequency_interval": "3", 
     "frequency": "Month", 
     "cycles": "1", 
     "amount": { 
      "currency": "CAD", 
      "value": "900.00" 
     }, 
     "charge_models": [ 
      { 
      "type": "TAX", 
      "amount": { 
       "currency": "CAD", 
       "value": "11.11" 
      } 
      }, 
      { 
      "type": "SHIPPING", 
      "amount": { 
       "currency": "CAD", 
       "value": "0.00" 
      } 
      } 
     ] 
     }, 
     { 
     "type": "REGULAR", 
     "frequency_interval": "1", 
     "frequency": "Month", 
     "cycles": "0", 
     "amount": { 
      "currency": "CAD", 
      "value": "300.00" 
     }, 
     "charge_models": [ 
      { 
      "type": "TAX", 
      "amount": { 
       "currency": "CAD", 
       "value": "22.22" 
      } 
      }, 
      { 
      "type": "SHIPPING", 
      "amount": { 
       "currency": "CAD", 
       "value": "0.00" 
      } 
      } 
     ] 
     } 
    ], 
    "merchant_preferences": { 
     "setup_fee": { 
     "currency": "CAD", 
     "value": "0.00" 
     }, 
     "max_fail_attempts": "0", 
     "auto_bill_amount": "YES" 
    } 
    }, 
    "links": [ 
    { 
     "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-HLK83FVHB5X2/suspend", 
     "rel": "suspend", 
     "method": "POST" 
    }, 
    { 
     "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-HLK83FVHB5X2/re-activate", 
     "rel": "re_activate", 
     "method": "POST" 
    }, 
    { 
     "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-HLK83FVHB5X2/cancel", 
     "rel": "cancel", 
     "method": "POST" 
    }, 
    { 
     "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-HLK83FVHB5X2/bill-balance", 
     "rel": "self", 
     "method": "POST" 
    }, 
    { 
     "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-HLK83FVHB5X2/set-balance", 
     "rel": "self", 
     "method": "POST" 
    } 
    ] 
} 

回答

1

你有兩個選擇 1:用於接收貝寶IPN(即時付款通知),以便他們將通知您在安裝如果協議被取消。

2:您可以隨時取回協議細節在https://developer.paypal.com/docs/api/#retrieve-an-agreement 提到它會給你響應這樣

 { 
     "id": "I-0LN988D3JACS", 
     "state": "Pending", 
     "description": "New Description", 
     "plan": { 
     "payment_definitions": [ 
      { 
      "type": "REGULAR", 
      "frequency": "Month", 
      "amount": { 
       "currency": "USD", 
       "value": "100.00" 
      }, 
      "charge_models": [ 
       { 
       "type": "TAX", 
       "amount": { 
        "currency": "USD", 
        "value": "12.00" 
       } 
       }, 
       { 
       "type": "SHIPPING", 
       "amount": { 
        "currency": "USD", 
        "value": "10.00" 
       } 
       } 
      ], 
      "cycles": "12", 
      "frequency_interval": "2" 
      } 
     ], 
     "merchant_preferences": { 
      "setup_fee": { 
      "currency": "USD", 
      "value": "0.00" 
      }, 
      "max_fail_attempts": "0", 
      "auto_bill_amount": "YES" 
     } 
     }, 
     "links": [ 
     { 
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-0LN988D3JACS/suspend", 
      "rel": "suspend", 
      "method": "POST" 
     }, 
     { 
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-0LN988D3JACS/re-activate", 
      "rel": "re_activate", 
      "method": "POST" 
     }, 
     { 
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-0LN988D3JACS/cancel", 
      "rel": "cancel", 
      "method": "POST" 
     }, 
     { 
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-0LN988D3JACS/bill-balance", 
      "rel": "self", 
      "method": "POST" 
     }, 
     { 
      "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-0LN988D3JACS/set-balance", 
      "rel": "self", 
      "method": "POST" 
     } 
     ], 
     "start_date": "2015-02-19T08:00:00Z", 
     "agreement_details": { 
     "outstanding_balance": { 
      "currency": "USD", 
      "value": "0.00" 
     }, 
     "cycles_remaining": "12", 
     "cycles_completed": "0", 
     "final_payment_date": "2016-12-19T10:00:00Z", 
     "failed_payment_count": "0" 
     } 
     } 
+0

我沒有任何的這些「狀況」,「agreement_details」,「cycle_remaining」請看我更新的問題。 – 2014-12-04 17:03:59

+0

這個答案正在考慮貝寶NVP/SOAP API,而問題是關於貝寶REST API。 – fiatjaf 2017-04-10 14:13:38