Commit 652d701ab789496d9bb9fd90a74687eb1add96fb
Committed by
GitHub
Exists in
master
Merge pull request #112 from liujavamail/master
feat: add sharing profit
Showing
1 changed file
with
66 additions
and
0 deletions
Show diff stats
lib/wx_pay/service.rb
... | ... | @@ -476,6 +476,72 @@ module WxPay |
476 | 476 | r |
477 | 477 | end |
478 | 478 | |
479 | + PROFITSHARINGADDRECEIVER = [:nonce_str, :receiver] | |
480 | + | |
481 | + # 添加分账接收方 | |
482 | + def self.profitsharingaddreceiver(params, options = {}) | |
483 | + params = { | |
484 | + appid: options.delete(:appid) || WxPay.appid, | |
485 | + mch_id: options.delete(:mch_id) || WxPay.mch_id, | |
486 | + nonce_str: SecureRandom.uuid.tr('-', ''), | |
487 | + key: options.delete(:key) || WxPay.key | |
488 | + }.merge(params) | |
489 | + | |
490 | + check_required_options(params, PROFITSHARINGADDRECEIVER) | |
491 | + | |
492 | + r = WxPay::Result.new(Hash.from_xml(invoke_remote("/pay/profitsharingaddreceiver", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options))) | |
493 | + | |
494 | + yield r if block_given? | |
495 | + | |
496 | + r | |
497 | + end | |
498 | + | |
499 | + PROFITSHARINGREMOVERECEIVER = [:nonce_str, :receiver] | |
500 | + # 删除分账接收方 | |
501 | + def self.profitsharingremovereceiver(params, options = {}) | |
502 | + params = { | |
503 | + appid: options.delete(:appid) || WxPay.appid, | |
504 | + mch_id: options.delete(:mch_id) || WxPay.mch_id, | |
505 | + nonce_str: SecureRandom.uuid.tr('-', ''), | |
506 | + key: options.delete(:key) || WxPay.key | |
507 | + }.merge(params) | |
508 | + | |
509 | + check_required_options(params, PROFITSHARINGADDRECEIVER) | |
510 | + | |
511 | + r = WxPay::Result.new(Hash.from_xml(invoke_remote("/pay/profitsharingremovereceiver", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options))) | |
512 | + | |
513 | + yield r if block_given? | |
514 | + | |
515 | + r | |
516 | + end | |
517 | + | |
518 | + # 单次分账 | |
519 | + | |
520 | + PROFITSHARING = [:nonce_str, :receivers, :transaction_id, :out_order_no] | |
521 | + | |
522 | + def self.profitsharing(params, options = {}) | |
523 | + params = { | |
524 | + appid: options.delete(:appid) || WxPay.appid, | |
525 | + mch_id: options.delete(:mch_id) || WxPay.mch_id, | |
526 | + nonce_str: SecureRandom.uuid.tr('-', ''), | |
527 | + key: options.delete(:key) || WxPay.key | |
528 | + }.merge(params) | |
529 | + | |
530 | + check_required_options(params, PROFITSHARING) | |
531 | + | |
532 | + options = { | |
533 | + ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert, | |
534 | + ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key, | |
535 | + verify_ssl: OpenSSL::SSL::VERIFY_NONE | |
536 | + }.merge(options) | |
537 | + | |
538 | + r = WxPay::Result.new(Hash.from_xml(invoke_remote("/secapi/pay/profitsharing", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options))) | |
539 | + | |
540 | + yield r if block_given? | |
541 | + | |
542 | + r | |
543 | + end | |
544 | + | |
479 | 545 | class << self |
480 | 546 | private |
481 | 547 | ... | ... |