lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.33.0 vs lib/active_merchant/billing/gateways/paypal_express.rb in activemerchant-1.34.0

- old
+ new

@@ -61,10 +61,14 @@ def store(token, options = {}) commit 'CreateBillingAgreement', build_create_billing_agreement_request(token, options) end + def unstore(token, options = {}) + commit 'BAUpdate', build_cancel_billing_agreement_request(token) + end + def authorize_reference_transaction(money, options = {}) requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip) commit 'DoReferenceTransaction', build_reference_transaction_request('Authorization', money, options) end @@ -180,9 +184,22 @@ xml = Builder::XmlMarkup.new :indent => 2 xml.tag! 'CreateBillingAgreementReq', 'xmlns' => PAYPAL_NAMESPACE do xml.tag! 'CreateBillingAgreementRequest', 'xmlns:n2' => EBAY_NAMESPACE do xml.tag! 'n2:Version', API_VERSION xml.tag! 'Token', token + end + end + + xml.target! + end + + def build_cancel_billing_agreement_request(token) + xml = Builder::XmlMarkup.new :indent => 2 + xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do + xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do + xml.tag! 'n2:Version', API_VERSION + xml.tag! 'ReferenceID', token + xml.tag! 'BillingAgreementStatus', "Canceled" end end xml.target! end